Ways to control the gzip_vary directive from nginx 0.6.34 and above?

Igor Sysoev is at rambler-co.ru
Tue Sep 15 12:23:38 MSD 2009


On Tue, Sep 15, 2009 at 04:20:48PM +0900, Zev Blut wrote:

> On 09/15/2009 02:48 PM, Igor Sysoev wrote:
> >On Tue, Sep 15, 2009 at 02:38:48PM +0900, Zev Blut wrote:
> 
> >>I don't think I have, but just in case here is a copy of my gzip commands:
> >>---------------------
> >># Serve up static compressed items
> >>gzip_static  on;
> >>
> >>## Compression
> >>gzip on;
> >>gzip_http_version 1.1;
> >>gzip_comp_level 2;
> >>gzip_proxied any;
> >>gzip_min_length  1100;
> >>gzip_buffers 16 8k;
> >>gzip_types text/plain text/html text/css application/x-javascript
> >>text/xml application/xml application/xml+rss text/javascript;
> >># Some version of IE 6 don't handle compression well on some mime-types,
> >>so just disable for them
> >>gzip_disable "MSIE [1-6].(?!.*SV1)";
> >># Set a vary header so downstream proxies don't send cached gzipped
> >>content to IE6
> >>gzip_vary on;
> >>---------------------
> >>
> >>But with these commands things like jpgs and mp3s are still getting the
> >>Vary: Accept-Encoding header, even though they are not compressed.
> >>Is there something I am missing?
> >
> >It should not.
> >Could you create debug log ?
> 
> Sure.
> 
> I have attached a debug log from 0.6.39 that has the Vary when it should 
> not.  If you would like I can also attach a debug log from 0.6.32 that 
> does not include the Vary (which is what I need).

This bug was fixed in 0.7.9.
The attached patch fixes it in 0.6.x, if you prefer to stay on this version.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/modules/ngx_http_gzip_filter_module.c
===================================================================
--- src/http/modules/ngx_http_gzip_filter_module.c	(revision 2448)
+++ src/http/modules/ngx_http_gzip_filter_module.c	(working copy)
@@ -221,8 +221,7 @@
         || (r->headers_out.content_encoding
             && r->headers_out.content_encoding->value.len)
         || (r->headers_out.content_length_n != -1
-            && r->headers_out.content_length_n < conf->min_length)
-        || ngx_http_gzip_ok(r) != NGX_OK)
+            && r->headers_out.content_length_n < conf->min_length))
     {
         return ngx_http_next_header_filter(r);
     }
@@ -241,6 +240,10 @@
 
 found:
 
+    if (ngx_http_gzip_ok(r) != NGX_OK) {
+        return ngx_http_next_header_filter(r);
+    }
+
     ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_gzip_ctx_t));
     if (ctx == NULL) {
         return NGX_ERROR;


More information about the nginx mailing list