How to cache HTTP proxies between a data service using gzip-encoded resources?

The HTTP server uses content negotiation to serve a single URL or gzip encoding based on the Accept-Encoding client header.

Now let's say that we have a proxy cache, like a squid between clients and httpd.

If the proxy server cached both URL encodings, how does it determine what to serve?

A non-gzip instance (not initially served by Vary ) can be sent to any client, but encoded instances (having Vary: Accept-Encoding ) can only be sent to clients with the same Accept-Encoding header value as was used in the initial request.

eg. Opera sends "deflate, gzip, x-gzip, identity, *;q=0" , but IE8 sends "gzip, deflate" . According to the specification, caches should not exchange caches encoded by content between two browsers. It's true?

+6
caching proxy reverse-proxy content-encoding
source share
3 answers

First of all, IMHO it is wrong to not send "Vary: Accept-Encoding" when the entity really changes by this header (or its absence).

Currently, the specification does indeed prohibit the display of a cached response on Opera, since the Vary header does not comply with the HTTPbis definitions , Part 6, Section 2.6 . Perhaps this is the area where we need to override the cache requirements (you can keep track of the IETF HTTP mailing list ...

UPDATE: it turns out that this has already been marked as an open question; I just added a problem to our problem tracker, see Problem 147 .

+7
source

Julian is right, of course. Lesson: Always send Vary: Accept-Encoding when sniffing Accept-Encoding , no matter what response encoding.

To answer my question, if you mistakenly leave Vary , if the proxy receives an unencrypted response (without Vary ), it can simply cache and return it for each subsequent request (ignoring Accept-Encoding ), Squid does this .

+1
source

The big problem with exiting Vary is that if the cache receives an encoded version without Vary, then it MAY send it in response to other requests, even if their Accept-Encoding indicates that the client cannot understand the contents.

+1
source

All Articles