Ways to control the gzip_vary directive from nginx 0.6.34 and above?

Igor Sysoev is at rambler-co.ru
Tue Sep 15 09:16:23 MSD 2009

On Tue, Sep 15, 2009 at 01:07:50PM +0900, Zev Blut wrote:

> Hello,
> Nginx 0.6.34 and above have changed the gzip_vary directive to add
> the "Vary: Accept-Encoding" header to uncompressed responses as well as
> compressed responses.
> The change is specifically:
> "
> Changes with nginx 0.6.34                                        27 Nov 2008
>    *) Change: now the "gzip_vary" directive turned on issues a
>       "Vary: Accept-Encoding" header line for uncompressed responses too.
> "
> Unfortunately for me, this change prevents us from using our CDN.
> Our CDN will not cache requests for non gzipped content that has the
> Vary header.  Thus, this defeats the purpose of our CDN for a large part
> of our image and audio content.
> For the time being, this means I have to remove the changes to the
> nginx_http_gzip_static_module.c to prevent this header from showing up.
> Short of hacking nginx_http_gzip_static_module.c, is there a way to prevent
> this Vary header from showing up with non-gzipped content? If not, would it
> be possible to make this directive configurable?

"gzip_vary on" adds the "Vary" header only to non-gzipped responses those
can be gzipped, but were not gzipped for some reasons: gzip_disable,
gzip_proxied, and gzip_http_version disable gzipping for some particular

Since image and audio content are not gzipable content at all, nginx will
not add this header in those responses.

> Also may I ask why this change was made?  Is there something I am
> missing relating to the HTTP spec for this?

The modern Squid versions keep several responses: gzipped and non-gzipped
ones and use appropriate one depending on "Accept-Encoding" header.

Igor Sysoev

More information about the nginx mailing list