<div dir="ltr">yup, just tested this today and works like a charm, thanks!<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 21, 2014 at 6:48 PM, Aaron Peschel <span dir="ltr"><<a href="mailto:aaron.peschel@gmail.com" target="_blank">aaron.peschel@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you for your help through this whole process, Maxim!<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Jun 25, 2014 at 3:40 PM, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br>
> details:   <a href="http://hg.nginx.org/nginx/rev/e491b26fa5a1" target="_blank">http://hg.nginx.org/nginx/rev/e491b26fa5a1</a><br>
> branches:<br>
> changeset: 5733:e491b26fa5a1<br>
> user:      Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>><br>
> date:      Thu Jun 26 02:21:01 2014 +0400<br>
> description:<br>
> Entity tags: downgrade strong etags to weak ones as needed.<br>
><br>
> See <a href="http://mailman.nginx.org/pipermail/nginx-devel/2013-November/004523.html" target="_blank">http://mailman.nginx.org/pipermail/nginx-devel/2013-November/004523.html</a>.<br>
><br>
> diffstat:<br>
><br>
>  src/http/modules/ngx_http_addition_filter_module.c |   2 +-<br>
>  src/http/modules/ngx_http_gunzip_filter_module.c   |   2 +-<br>
>  src/http/modules/ngx_http_gzip_filter_module.c     |   2 +-<br>
>  src/http/modules/ngx_http_ssi_filter_module.c      |   5 ++-<br>
>  src/http/modules/ngx_http_sub_filter_module.c      |   5 ++-<br>
>  src/http/modules/ngx_http_xslt_filter_module.c     |   6 ++-<br>
>  src/http/ngx_http_core_module.c                    |  40 ++++++++++++++++++++++<br>
>  src/http/ngx_http_core_module.h                    |   1 +<br>
>  8 files changed, 56 insertions(+), 7 deletions(-)<br>
><br>
> diffs (153 lines):<br>
><br>
> diff --git a/src/http/modules/ngx_http_addition_filter_module.c b/src/http/modules/ngx_http_addition_filter_module.c<br>
> --- a/src/http/modules/ngx_http_addition_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_addition_filter_module.c<br>
> @@ -121,7 +121,7 @@ ngx_http_addition_header_filter(ngx_http<br>
><br>
>      ngx_http_clear_content_length(r);<br>
>      ngx_http_clear_accept_ranges(r);<br>
> -    ngx_http_clear_etag(r);<br>
> +    ngx_http_weak_etag(r);<br>
><br>
>      return ngx_http_next_header_filter(r);<br>
>  }<br>
> diff --git a/src/http/modules/ngx_http_gunzip_filter_module.c b/src/http/modules/ngx_http_gunzip_filter_module.c<br>
> --- a/src/http/modules/ngx_http_gunzip_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_gunzip_filter_module.c<br>
> @@ -165,7 +165,7 @@ ngx_http_gunzip_header_filter(ngx_http_r<br>
><br>
>      ngx_http_clear_content_length(r);<br>
>      ngx_http_clear_accept_ranges(r);<br>
> -    ngx_http_clear_etag(r);<br>
> +    ngx_http_weak_etag(r);<br>
><br>
>      return ngx_http_next_header_filter(r);<br>
>  }<br>
> diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c<br>
> --- a/src/http/modules/ngx_http_gzip_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_gzip_filter_module.c<br>
> @@ -306,7 +306,7 @@ ngx_http_gzip_header_filter(ngx_http_req<br>
><br>
>      ngx_http_clear_content_length(r);<br>
>      ngx_http_clear_accept_ranges(r);<br>
> -    ngx_http_clear_etag(r);<br>
> +    ngx_http_weak_etag(r);<br>
><br>
>      return ngx_http_next_header_filter(r);<br>
>  }<br>
> diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c<br>
> --- a/src/http/modules/ngx_http_ssi_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_ssi_filter_module.c<br>
> @@ -369,10 +369,13 @@ ngx_http_ssi_header_filter(ngx_http_requ<br>
>      if (r == r->main) {<br>
>          ngx_http_clear_content_length(r);<br>
>          ngx_http_clear_accept_ranges(r);<br>
> -        ngx_http_clear_etag(r);<br>
><br>
>          if (!slcf->last_modified) {<br>
>              ngx_http_clear_last_modified(r);<br>
> +            ngx_http_clear_etag(r);<br>
> +<br>
> +        } else {<br>
> +            ngx_http_weak_etag(r);<br>
>          }<br>
>      }<br>
><br>
> diff --git a/src/http/modules/ngx_http_sub_filter_module.c b/src/http/modules/ngx_http_sub_filter_module.c<br>
> --- a/src/http/modules/ngx_http_sub_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_sub_filter_module.c<br>
> @@ -175,10 +175,13 @@ ngx_http_sub_header_filter(ngx_http_requ<br>
><br>
>      if (r == r->main) {<br>
>          ngx_http_clear_content_length(r);<br>
> -        ngx_http_clear_etag(r);<br>
><br>
>          if (!slcf->last_modified) {<br>
>              ngx_http_clear_last_modified(r);<br>
> +            ngx_http_clear_etag(r);<br>
> +<br>
> +        } else {<br>
> +            ngx_http_weak_etag(r);<br>
>          }<br>
>      }<br>
><br>
> diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c<br>
> --- a/src/http/modules/ngx_http_xslt_filter_module.c<br>
> +++ b/src/http/modules/ngx_http_xslt_filter_module.c<br>
> @@ -337,12 +337,14 @@ ngx_http_xslt_send(ngx_http_request_t *r<br>
>              r->headers_out.content_length = NULL;<br>
>          }<br>
><br>
> -        ngx_http_clear_etag(r);<br>
> -<br>
>          conf = ngx_http_get_module_loc_conf(r, ngx_http_xslt_filter_module);<br>
><br>
>          if (!conf->last_modified) {<br>
>              ngx_http_clear_last_modified(r);<br>
> +            ngx_http_clear_etag(r);<br>
> +<br>
> +        } else {<br>
> +            ngx_http_weak_etag(r);<br>
>          }<br>
>      }<br>
><br>
> diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c<br>
> --- a/src/http/ngx_http_core_module.c<br>
> +++ b/src/http/ngx_http_core_module.c<br>
> @@ -1851,6 +1851,46 @@ ngx_http_set_etag(ngx_http_request_t *r)<br>
>  }<br>
><br>
><br>
> +void<br>
> +ngx_http_weak_etag(ngx_http_request_t *r)<br>
> +{<br>
> +    size_t            len;<br>
> +    u_char           *p;<br>
> +    ngx_table_elt_t  *etag;<br>
> +<br>
> +    etag = r->headers_out.etag;<br>
> +<br>
> +    if (etag == NULL) {<br>
> +        return;<br>
> +    }<br>
> +<br>
> +    if (etag->value.len > 2<br>
> +        && etag->value.data[0] == 'W'<br>
> +        && etag->value.data[1] == '/')<br>
> +    {<br>
> +        return;<br>
> +    }<br>
> +<br>
> +    if (etag->value.len < 1 || etag->value.data[0] != '"') {<br>
> +        r->headers_out.etag->hash = 0;<br>
> +        r->headers_out.etag = NULL;<br>
> +        return;<br>
> +    }<br>
> +<br>
> +    p = ngx_pnalloc(r->pool, etag->value.len + 2);<br>
> +    if (p == NULL) {<br>
> +        r->headers_out.etag->hash = 0;<br>
> +        r->headers_out.etag = NULL;<br>
> +        return;<br>
> +    }<br>
> +<br>
> +    len = ngx_sprintf(p, "W/%V", &etag->value) - p;<br>
> +<br>
> +    etag->value.data = p;<br>
> +    etag->value.len = len;<br>
> +}<br>
> +<br>
> +<br>
>  ngx_int_t<br>
>  ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,<br>
>      ngx_str_t *ct, ngx_http_complex_value_t *cv)<br>
> diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h<br>
> --- a/src/http/ngx_http_core_module.h<br>
> +++ b/src/http/ngx_http_core_module.h<br>
> @@ -501,6 +501,7 @@ void *ngx_http_test_content_type(ngx_htt<br>
>  ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);<br>
>  void ngx_http_set_exten(ngx_http_request_t *r);<br>
>  ngx_int_t ngx_http_set_etag(ngx_http_request_t *r);<br>
> +void ngx_http_weak_etag(ngx_http_request_t *r);<br>
>  ngx_int_t ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,<br>
>      ngx_str_t *ct, ngx_http_complex_value_t *cv);<br>
>  u_char *ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *name,<br>
><br>
> _______________________________________________<br>
> nginx-devel mailing list<br>
> <a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
> <a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</div></div></blockquote></div><br></div>