# Gzip\_disable and vary header

**URL:** <https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556>\
**Category:** NGINX\
**Created:** [April 2, 2009, 3:48pm UTC](https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556 "2009-04-02T15:48:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spilgames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@spilgames](https://www.ruby-forum.com/u/spilgames)\
**Post date:** [April 2, 2009, 3:48pm UTC](https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556/1 "2009-04-02T15:48:09Z")

</div>

Hi,

A while ago we were having some troubles with gzip and old IE6. I then  
found this blog entry which seemed to solve my troubles:

> **[Home](https://robsanheim.com)**
>
> Just another WordPress site

However immediately after applying this fix to our Nginx config files I  
realised that there was still something wrong. If gzip\_disable acts on  
the User-Agent to enable/disable compression, shouldn’t gzip\_vary act on  
this too? In other words shouldn’t it send this header?:

Vary: Accept-Encoding, User-Agent

Attached patch modifies Nginx 0.6 to send above header when both  
gzip\_vary and gzip\_disable are being used. It reverts back to the old  
behaviour of sending only Accept-Encoding in the Vary header if  
gzip\_disable is not in use.

Feedback appreciated.

Regards,

Matthijs van der Klip

---

<div class="post-metadata">

**Author:** ![spilgames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@spilgames](https://www.ruby-forum.com/u/spilgames)\
**Post date:** [June 25, 2009, 1:45pm UTC](https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556/2 "2009-06-25T13:45:05Z")

</div>

Hello,

On Apr 2, 2009, at 15:48 , Spil G. wrote:

> realised that there was still something wrong. If gzip\_disable acts on  
> the User-Agent to enable/disable compression, shouldn’t gzip\_vary  
> act on  
> this too? In other words shouldn’t it send this header?:
> 
> Vary: Accept-Encoding, User-Agent

I’ve found yet another resource that indicate that the current  
behavior of nginx is incorrect:

> **[REDbot](https://redbot.org/?uri=http%3A%2F%2Fnginx.net)**
>
> REDbot is lint for your HTTP resources.

I can’t find what SPEC it is relying on, but as far as other  
discussions on The Internets go, I think that Accept-encoding is  
indeed required.

> Attached patch modifies Nginx 0.6 to send above header when both  
> gzip\_vary and gzip\_disable are being used. It reverts back to the old  
> behaviour of sending only Accept-Encoding in the Vary header if  
> gzip\_disable is not in use.
> 
> Feedback appreciated.

I can confirm that this works as intended. I’ve attached a patch  
against nginx 0.8.4 which is based on the earlier patch.

> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Thanks,  
Johan

---

<div class="post-metadata">

**Author:** ![spilgames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@spilgames](https://www.ruby-forum.com/u/spilgames)\
**Post date:** [June 29, 2009, 10:18pm UTC](https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556/3 "2009-06-29T22:18:58Z")

</div>

On Jun 25, Johan Bergström wrote:

> > 
> 
> I can’t find what SPEC it is relying on, but as far as other discussions on  
> The Internets go, I think that Accept-encoding is indeed required.

Accept-Encoding most definitely needs to go as part of Vary when gzip in  
place. While adding User-Agent to Vary seems tempting, it has a side  
effect of severely decreasing your cache-hit ratio since every  
build/patch of a browser has a different UA string.

---

<div class="post-metadata">

**Author:** ![spilgames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@spilgames](https://www.ruby-forum.com/u/spilgames)\
**Post date:** [June 30, 2009, 9:15am UTC](https://www.ruby-forum.com/t/gzip-disable-and-vary-header/164556/4 "2009-06-30T09:15:37Z")

</div>

Arvind Jayaprakash wrote:

> Accept-Encoding most definitely needs to go as part of Vary when gzip in  
> place. While adding User-Agent to Vary seems tempting, it has a side  
> effect of severely decreasing your cache-hit ratio since every  
> build/patch of a browser has a different UA string.

Most defenitely true, but the alternative is having either the  
compressed or uncompressed version of a response being cached depending  
on “luck”. If you want to prevent the cache-hit ratio problem, you  
should avoid using the gzip\_disable feature if you ask me.
