Nginx – Disable User-Agent based Vary header response in nginx

httphttp-headersnginx

It seems that nginx includes a Vary: Accept-Encoding header in some cases regardless of the file types I specify via "gzip_types".

I do not have much experience with nginx. Does it in fact send Vary: Accept-Encoding headers depending on the requesting User-Agent header?

Also, is there a setting (or combination of settings) that can be modified in order to stop nginx from sending Vary: Accept-Encoding headers for specific User-Agents?

There seem to be quite a few settings and I simply do not know which take precedence.

I suppose something like the following would not achieve what I want (I still want the Vary: Accept-Encoding response for file types only):
gzip_disable "*";

Best Answer

I don't understand why you'd want to change this. Vary: tells any caching proxy that it can not rely purely on the URL to cache the result and that it also needs to take into account of the Accept-Encoding: header too. This is the correct behaviour. You are going to get a different response if your client says it can deal with compressed responses or not. Without this header, a cache may attempt to send a compressed response to a client that can't handle it.