clearing etags when gzipping
Maxim Dounin
mdounin at mdounin.ru
Mon Nov 26 18:54:39 UTC 2012
Hello!
On Thu, Nov 22, 2012 at 08:05:57PM -0500, Jeff Kaufman wrote:
> On Wed, Nov 21, 2012 at 4:02 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> >
> > >
> > > What would you think of simply not clearing the etag when it's already weak?
> >
> > I think it would be ok.
> >
>
> How do you want patches submitted? Is this good?
>
> --- nginx-1.3.8/src/http/modules/ngx_http_gzip_filter_module.c
> 2012-07-07 17:22:27.000000000 -0400
> +++ nginx-1.3.8-weak-etags-shorter/src/http/modules/ngx_http_gzip_filter_module.c2012-11-21
> 17:05:12.758389000 -0500
> @@ -306,7 +306,15 @@
>
> ngx_http_clear_content_length(r);
> ngx_http_clear_accept_ranges(r);
> - ngx_http_clear_etag(r);
> +
> + /* Clear etags unless they're marked as weak (prefixed with 'W/') */
> + h = r->headers_out.etag;
> + if (h && !(h->value.len >= 3 &&
> + h->value.data[0] == 'W' &&
> + h->value.data[1] == '/' &&
> + h->value.data[2] == '"')) {
> + ngx_http_clear_etag(r);
> + }
>
> return ngx_http_next_header_filter(r);
> }
Uhm, this is not something I would like to commit. It should be a
macro, probably something like
ngx_http_clear_strong_etag(r);
Much like ngx_http_clear_etag() itself.
It would be also good idea to audit other uses of
ngx_http_clear_etag() to see if they also deserve changing to a
new macro introduced. Rule of thumb seems to be: we want to
clear strong etags only if we clear Accept-Ranges but not
Last-Modified.
Style also needs fixing to match one used in nginx.
--
Maxim Dounin
http://nginx.com/support.html
More information about the nginx-devel
mailing list