Why don't Akamai servers cache objects if the origin server's Vary header contains anything other than Accept-Encoding?
This is necessary to prevent different versions of content from being cached and then later served to end users for which they are not intended. For instance, this prevents pages in one language from being cached and served to users of another language, or pages designed specifically for a certain browser from being cached and then served to users on another browser.
The HTTP Vary header is used by servers to indicate that the object being served will vary (the content will be different) based on some attribute of the incoming request, such as the requesting client's specified user-agent or language. The Akamai servers cannot cache different versions of the content based on the values of the Vary header. As a result, objects received with a Vary header that contains any value(s) other than "Accept-Encoding" will not be cached. To do so might result in some users receiving the incorrect version of the content (wrong language, etc.)
An "Accept-Encoding" value to the Vary header is the exception to this rule only when it relates to serving the object compressed. Since compression does not change the content of the object (only its size for transfer), an object that varies only by its compression can be safely cached.
To summarize, Akamai servers will cache the object, based on the configuration settings, in either of the following cases:
- If "Vary: Accept-Encoding" is received and the content is served compressed ("Content-Encoding: gzip").
- If no Vary header at all is received.
More detailed description of Vary and Accept-Encoding header interaction:
"Vary: Accept-Encoding" from the origin server indicates that the object served varies based on values received in the Accept-Encoding header of the incoming client request. For instance, the Akamai servers send the header "Accept-Encoding: gzip" in their forward requests to tell the origin server that gzip compression is supported. It is expected that the origin server will respond with the "Vary: Accept-Encoding" and "Content-Encoding: gzip" headers if serving the object compressed, or with no Vary header at all if serving the object uncompressed. Any other combination, such as other values in the Vary header or no "Content-Encoding: gzip" header in the response, indicates that the object varies in some way other than compression (that its actual content may be different), and therefore should not be cached.
Comments
0 comments
Please sign in to leave a comment.