Making cachefu page purging work with vary headers : one solution nuke the Accept-Language <-- is this wise?

Rob Rogers robertbrogers at gmail.com
Wed Mar 17 11:21:00 CET 2010


The issue:
html type pages (think objects in zope) cached in varnish, were not  
purged successfully with zope/plone/cachefu purging methods.
Images were purged. but html content was not.

Given we depend on caching pages in accelerator/zope/plone this is  a  
showstopper. (e.g. we use this:  cache-in-proxy-1-hour for (most) html  
content)

In order to make purging work, I had to normalize or unset a couple  
http.req attributes. This is what I came up with.

The 'working' solution:
sub vcl_recv {
	...
         if (req.http.Accept-Encoding) { /* lifted from varnish site */
           if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
                         # No point in compressing these
             remove req.http.Accept-Encoding;
           } elsif (req.http.Accept-Encoding ~ "gzip") {
             set req.http.Accept-Encoding = "gzip";
           } elsif (req.http.Accept-Encoding ~ "deflate") {
             set req.http.Accept-Encoding = "deflate";
           } else {
                         # unkown algorithm
             remove req.http.Accept-Encoding;
           }
         }
         unset req.http.Accept-Language; /* is this DANGEROUS? */
         unset req.http.user-agent;
         set req.http.host = "my.cashmoney.com";
	...
}

Based on what I have read, unsetting these attributes help keep  
multiple cache objects to a minimum.
Which is the reasoning behind normalizing the Accept-Encoding per http://varnish-cache.org/wiki/FAQ/Compression

So, I guess I have 2 questions:
1) Given the site is only served in english, is there a danger of  
serving up the wrong hit for a browser with a different Accept-Language?
2) Will I still get purge misses for objects  cached by some browsers,  
like ones presenting deflate instead of gzip in the header?


Thanks,

Rob







More information about the varnish-misc mailing list