Not seeing a successful purge

Tollef Fog Heen tfheen at
Mon Feb 15 09:29:58 CET 2010

]] John Norman 

| I think it's the backend's (Apache/Passenger) header:
|     Vary: Accept-Encoding,User-Agent
| Which seems to prevent (???) this from working in my vcl_hash:
|   if (req.http.Accept-Encoding ~ "gzip") {
|     set req.hash += "gzip";
|   } // etc

No, that works fine, but is useless.  Varnish does Vary handling

| The Varnish doc says: "But by default, Varnish will perform no
| transforms on the headers singled out by Vary: for comparison"
| (

Yes, this means that if you know your backend only cares about
gzip/non-gzip, you should normalise the header in vcl_recv.  Varnish
can't know this, as it requires knowledge of your backend and

However, even if you changed that, you still have a Vary on
user-agent. This is generally a really bad idea, and you should try to
see if you can vary on something else.  If you don't, you are going to
see poor hit rates. (Assuming that you're not just caching for a
corporate intranet where everybody has _exactly_ the same versions of
browser, etc.)

| So . . . I'm not sure what I should do. If the backend says "Vary" for
| Accept-Encoding, does that mean that I should or should not be able to
| access that header for the purposes of setting the hash?

Normalise Accept-Encoding, stop adding it to the hash.

| What I am observing is:
| browser makes request with Accept-Encoding: gzip,deflate
| When I try to purge, the request with the purge says: Accept-Encoding:
| gzip,identity
| Even though "gzip" is in the request for both the browser
| Accept-Encoding, and for the purge, they seem to be getting hashed
| differently.

No, they hash to the same object but as the Vary-ed string differs the
Vary handling makes it out to be different objects.

Tollef Fog Heen 
Redpill Linpro -- Changing the game!
t: +47 21 54 41 73

More information about the varnish-misc mailing list