Purge based on url postfix

Hauke Lampe lampe at hauke-lampe.de
Thu Dec 29 12:35:57 CET 2011


On 28.12.2011 15:12, Lars Jørgensen wrote:

> I'm stumped on how to extract the original url from that request,
> though.

regsub(str, regex, sub)
    Returns a copy of str with the first occurrence of the regular
    expression regex replaced with sub. Within sub, 0 (which can also
    be spelled &) is replaced with the entire matched string, and n is
    replaced with the contents of subgroup n in the matched string.

https://www.varnish-cache.org/docs/3.0/reference/vcl.html#functions

i.e. something like this should work:
set req.url = regsub(req.url, "\$PURGE$", "");


> As a workaround, I would like to enable CMS editors to call content with a postfixed string to purge it. Like this: www.website.com/index.html$PURGE 

I use a special request header to force a cache miss and retrieve
updated content from the backend:

if (req.http.X-FreshForce == "yes") {
  # Force a cache miss
  set req.hash_always_miss = true;
}

CMS editors have a button in their browsers to enable the X-FreshForce
header, e.g. by using http://www.garethhunt.com/modifyheaders/ or similar.


Hauke

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20111229/7651559c/attachment.pgp>


More information about the varnish-misc mailing list