clearing etags when gzipping

Jeff Kaufman jefftk at google.com
Fri Nov 23 01:05:57 UTC 2012


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);
 }



More information about the nginx-devel mailing list