# Gzip\_disable doesn't disable gzip\_vary

**URL:** <https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467>\
**Category:** NGINX\
**Created:** [March 2, 2012, 8:09am UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467 "2012-03-02T08:09:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 2, 2012, 8:09am UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/1 "2012-03-02T08:09:07Z")

</div>

I noticed that with this setting:

gzip on;  
gzip\_vary on;  
gzip\_disable “msie6”;

Header “Vary: Accept-Encoding” will always be returned even though the  
user agent is ie6 (and therefore not using gzip):

# curl -I [http://animebsd.net/about/feed](http://animebsd.net/about/feed) -A "Mozilla/4.0 (compatible;

MSIE 6.0; Windows NT 5.0)"  
HTTP/1.1 200 OK  
Server: nginx/1.1.14  
Date: Fri, 02 Mar 2012 07:04:25 GMT  
Content-Type: text/xml; charset=UTF-8  
Connection: keep-alive  
Vary: Accept-Encoding  
X-Pingback: [http://animebsd.net/xmlrpc.php](http://animebsd.net/xmlrpc.php)  
Last-Modified: Fri, 02 Mar 2012 04:17:00 GMT  
ETag: “92a5989a0949b85e303228490256ebf2”  
X-Powered-By: W3 Total Cache/0.9.2.4  
Link: [http://wp.me/Pig2n-5B](http://wp.me/Pig2n-5B); rel=shortlink

I don’t think this is intentional as getting non-gzipped content  
doesn’t return such header. (I’ve verified this is returned by nginx  
by running same test with disabled gzip\_vary)

(I don’t see mention of this being fixed in .15 and .16 in the  
changelog so I haven’t tested with them)

---

<div class="post-metadata">

**Author:** ![Edho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@Edho\_A](https://www.ruby-forum.com/u/Edho_A)\
**Post date:** [March 2, 2012, 10:59am UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/2 "2012-03-02T10:59:55Z")

</div>

Hello!

On Fri, Mar 02, 2012 at 02:08:05PM +0700, Edho A. wrote:

> MSIE 6.0; Windows NT 5.0)"  
> Link: [http://wp.me/Pig2n-5B](http://wp.me/Pig2n-5B); rel=shortlink
> 
> I don’t think this is intentional as getting non-gzipped content  
> doesn’t return such header. (I’ve verified this is returned by nginx  
> by running same test with disabled gzip\_vary)

This is intentional, “Vary” is returned whenever gzip (and  
gzip\_vary) is enabled, as response representation depends on  
header(s) listed.

Strictly speaking, it should also include User-Agent in case of  
gzip\_disable defined.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Edho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@Edho\_A](https://www.ruby-forum.com/u/Edho_A)\
**Post date:** [March 2, 2012, 11:16am UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/3 "2012-03-02T11:16:03Z")

</div>

2012/3/2 Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> This is intentional, “Vary” is returned whenever gzip (and  
> gzip\_vary) is enabled, as response representation depends on  
> header(s) listed.
> 
> Strictly speaking, it should also include User-Agent in case of  
> gzip\_disable defined.

Shouldn’t there be no change to header at all when client user agent  
matches the gzip\_disabled (ie. just like with gzip off)?

---

<div class="post-metadata">

**Author:** ![Edho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@Edho\_A](https://www.ruby-forum.com/u/Edho_A)\
**Post date:** [March 2, 2012, 12:21pm UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/4 "2012-03-02T12:21:17Z")

</div>

Hello!

On Fri, Mar 02, 2012 at 05:15:07PM +0700, Edho A. wrote:

> Shouldn’t there be no change to header at all when client user agent  
> matches the gzip\_disabled (ie. just like with gzip off)?

> **[RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 | RFC Editor](https://www.rfc-editor.org/info/rfc2616/)**
>
> HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as "HTTP/1.1", and is an update to RFC 2068. \[STANDARDS-TRACK\]

An HTTP/1.1 server SHOULD include a Vary header field with any  
cacheable response that is subject to server-driven negotiation.

For sure with gzip enabled the response “is subject to server-driven  
negotiation”.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Edho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@Edho\_A](https://www.ruby-forum.com/u/Edho_A)\
**Post date:** [March 2, 2012, 12:43pm UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/5 "2012-03-02T12:43:00Z")

</div>

2012/3/2 Maxim D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

So, the “gzip enabled response” includes cases with non-gzip content as:

- no “Accept-Encoding: gzip,deflate”
- matches gzip\_disabled  
and therefore “Vary: Accept-Encoding” will always be added even though  
the response isn’t compressed?

Or in other words, does “gzip on; gzip\_vary on” means “add ‘Vary:  
Accept-Encoding’ header on any responses matching gzip\_types  
regardless whether the response actually compressed or not”?

---

<div class="post-metadata">

**Author:** ![Edho\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@Edho\_A](https://www.ruby-forum.com/u/Edho_A)\
**Post date:** [March 2, 2012, 1:33pm UTC](https://www.ruby-forum.com/t/gzip-disable-doesnt-disable-gzip-vary/217467/6 "2012-03-02T13:33:55Z")

</div>

Hello!

On Fri, Mar 02, 2012 at 06:41:50PM +0700, Edho A. wrote:

> > negotiation".  
> > regardless whether the response actually compressed or not"?  
> > Yes.

Maxim D.
