As an httpZip or ZipEnable evaluator you may have noticed that compressed responses are returned with the Vary: Accept-Encoding header. In a nutshell, here’s why it’s there…
Say you have a proxy server that is caching your responses. It could be yours or it could be one that your visitors are connecting through. This proxy is doing its job of off-loading connections to your web server and quickly serving cacheable files to your users. Everything's going fine.
Now say you've decided to add a compression module to your web server to compress your outgoing files. This is even better. You're compressing and caching your outbound files whenever you can. What's the problem here? Well, it's that you've introduced a situation where a form of content negotiation needs to take place to prevent problems from occurring.
Consider what happens when a user makes a request for a file that is cached on one of these proxy servers with a user agent that does not support decompression. How is the proxy to determine whether it has a suitable file to send? It is likely to end up with both a compressed and an uncompressed version of the file. What is needed is a way to distinguish between two versions of the same file.
Here's where the VARY header comes in.
Acceptable parameters for the Vary header include the HTTP headers from the request that must be used in negotiating which file is suitable for sending. For example, when httpZip sends a Vary: Accept-Encoding header with a compressed response, this tells the proxy that if it caches the file, it must only return that file to a user agent with the same Accept-encoding request header value as the original requester. Problem solved. Simply and elegantly. That's it in a nutshell.
Of course, in reality it was a lot more like a sausage than a nut. There was a lot of debate about whether and how the Vary header was suitable for handling the content negotiation in the case of HTTP compression. There are some serious limitations in the way the Vary header is supposed to work. They are much more obvious in cases of content negotiation based on things like language preferences when q-ratings are introduced. But that’s a different case with its own set of raging debates.