nginx gzip doesn't (always) respect Accept-Encoding header?

Ed W lists at wildgooses.com
Wed Jun 1 01:19:54 MSD 2011


Hi, I seem to be missing an obvious step to control nginx gzip based (only) on the clients Accept-Encoding header?

Nginx 0.8.53. My config is:

gzip on;
gzip_min_length 900;
gzip_buffers    16 8k;
# how to gzip proxied content
gzip_proxied any;
gzip_vary on;
gzip_types      text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

gzip_http_version 1.1;
gzip_comp_level 6;
gzip_disable     "msie6";



Test 1
Using Firefox (use about:config) I change my Accept-Encoding header to be blank and now Firefox show me a page of unprintable characters (gzipped content is still sent but apparently not decoded by Firefox)

Test 2
I delete the "gzip_proxied any" directive - this time my Accept-Header choice is respected and content is not gzipped (and readable).  Resetting my Accept-Header back to default and once again content is gzip'ed (and readable)


So, it would appear that the directive gzip_proxied, also controls whether nginx respects the Accept-Encoding header?  This seems unexpected (and undesirable)?  My goal would be to compress all content purely based on the Accept-Header and disregard and Via headers (if the proxy is dim enough to request gzipped content and can't handle it, then it's there problem)

Is this behaviour expected? Changed in some later release?

Thanks

Ed W



More information about the nginx mailing list