Accept-Encoding: gzip and the Vary header

Maxim Dounin mdounin at
Thu Jun 4 13:11:25 UTC 2015


On Thu, Jun 04, 2015 at 11:49:18AM +0200, Xavier Noria wrote:

> On Thu, Jun 4, 2015 at 10:56 AM, Jason Woods <devel at> wrote:
> An HTTP/1.1 server SHOULD include a Vary header field with any
> >    cacheable response that is subject to server-driven negotiation.
> >    Doing so allows a cache to properly interpret future requests on that
> >    resource and informs the user agent about the presence of negotiation on that resource.
> >
> >
> You are right, and the section about server-driven negotiation
> explicitly mentions Accept-Encoding as an example. So case closed.
> Next question is: why is gzip_vary off by default? Isn't the most common
> case that you want it enabled?

The problem with Vary is that it causes bad effects on shared caches, in 
particular, it normaly results in cache duplication.  So by 
default nginx doesn't add Vary, and also doesn't send compressed 
content to proxies (gzip_proxied off).  This approach works with 
both HTTP/1.0 and HTTP/1.1 caches, and doesn't cause cache 

See related discussion in this thread:

Maxim Dounin

More information about the nginx mailing list