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

Laurence Rowe l at lrowe.co.uk
Wed Mar 17 12:57:51 CET 2010


Take a look at my improved vcl for plone.recipe.varnish here:

http://dev.plone.org/collective/browser/buildout/plone.recipe.varnish/branches/elro-better-vcl/plone/recipe/varnish/template.vcl

While you do want to normalize Accept-Encoding (remember Zope only
does gzip) you still have to account for browsers which do not handle
gzip. As there is currently no way to invalidate varies, I use purge
to add it to the ban list.

You should just set English as the only allowed language in
portal_languages to prevent internationalization of message strings.

Laurence

On 17 March 2010 10:21, Rob Rogers <robertbrogers at gmail.com> wrote:
> 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
>
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
>




More information about the varnish-misc mailing list