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

Laurence Rowe l at lrowe.co.uk
Thu Mar 18 13:58:20 CET 2010


See the two ways of purging: http://varnish-cache.org/wiki/VCLExamplePurging

purge() adds regular expressions to a ban list which is checked before
a cached copy is served.

The easiest way to use that recipe is probably to check out the branch
(pinned at a version, as I will eventually get around to working on it
again) into your buildout and develop it. The mr.developer extension
is a good way to do this.

Laurence

On 18 March 2010 06:13, Rob Rogers <robertbrogers at gmail.com> wrote:
> Laurence.
>
> First thank you so much.
>
> Second, you say:
>>
>> I use purge
>> to add it to the ban list.
>
> What is the ban list? And, how can I replicate this? (I don't see it
> referenced in your recipe template.)
>
> Finally, at the risk of sounding a total fool, how do a swap your recipe in
> place of the current one for the buildout?
> Just clobber this one:
> ./eggs/plone.recipe.varnish-1.0.2-py2.4.egg/plone/recipe/varnish/template.vcl
> ?
>
> Cheers,
>
> -Rob
>
>
> On Mar 17, 2010, at 4:57 AM, Laurence Rowe wrote:
>
>> 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