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

**URL:** <https://www.ruby-forum.com/t/nginx-gzip-doesnt-always-respect-accept-encoding-header/207697>\
**Category:** NGINX\
**Created:** [May 31, 2011, 11:20pm UTC](https://www.ruby-forum.com/t/nginx-gzip-doesnt-always-respect-accept-encoding-header/207697 "2011-05-31T23:20:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 31, 2011, 11:20pm UTC](https://www.ruby-forum.com/t/nginx-gzip-doesnt-always-respect-accept-encoding-header/207697/1 "2011-05-31T23:20:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ewildgoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewildgoose](https://www.ruby-forum.com/u/ewildgoose)\
**Post date:** [June 1, 2011, 12:34am UTC](https://www.ruby-forum.com/t/nginx-gzip-doesnt-always-respect-accept-encoding-header/207697/2 "2011-06-01T00:34:36Z")

</div>

Hello!

On Tue, May 31, 2011 at 10:19:54PM +0100, Ed W wrote:

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

[…]

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

Are you sure content is actually “sent”? I suspect it’s extracted by  
Firefox from it’s cache instead.

Maxim D.

---

<div class="post-metadata">

**Author:** ![ewildgoose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewildgoose](https://www.ruby-forum.com/u/ewildgoose)\
**Post date:** [June 1, 2011, 12:36pm UTC](https://www.ruby-forum.com/t/nginx-gzip-doesnt-always-respect-accept-encoding-header/207697/3 "2011-06-01T12:36:02Z")

</div>

On 31/05/2011 23:34, Maxim D. wrote:

> > 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)
> 
> Are you sure content is actually “sent”? I suspect it’s extracted by  
> Firefox from it’s cache instead.

Hmm, I believe it was sent because I could see the file size changing?  
However, I have upgraded to nginx 1.0 and repeated the test and I see no  
problem now.

At worst I guess it’s something which is fixed, will also concede user  
error though! Seems fine in any case

Thanks so much for nginx

Ed W
