Accept-Encoding: gzip and the Vary header

Xavier Noria fxn at
Thu Jun 4 19:36:43 UTC 2015

Ahhh, I see.

We've seen that if you want cache + compression, then you need Vary. So
by counter-reciprocal the trade-off of gzip_vary off is that the response
can't be cached at all in the sense that you're not sending the proper
headers. *No matter if the cache is private or shared*. At least in theory.

If you turn gzip_vary on to get some caching, but keep gzip_proxied off,
and Cache-Control is "public", then I guess clients behind those shared
caches would get uncompressed content unless the shared caches themselves
compress on the fly (does that happen?)

In the typical use case of a CSS file with a fingerprint in its filename
for aggressive caching I guess you actually need to go with (off the top of
my head):

    gzip_vary on;
    gzip_proxied on;

    expires max;
    add_header Cache-Control "public";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list