Purge based on url postfix
Lars Jørgensen
ljorg6 at gmail.com
Wed Dec 28 15:12:45 CET 2011
Hi,
We're having trouble getting our heavily customized backend to purge
changed pages automatically from Varnish.
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
That should purge index.html from the cache.
I'm stumped on how to extract the original url from that request,
though. I got this far:
sub vcl_recv {
if (req.url ~ "\$PURGE$") {
$original_url = some magic code to strip "$PURGE" from req.url
set req.x-purge = 1;
set req.url = $original_url;
}
}
sub vcl_hit {
if (req.x-purge == 1) {
purge;
error 200 "Purged";
}
}
sub vcl_miss {
if (req.x-purge == 1) {
error 404 "Page not in cache";
}
}
Is this the right way to go about it, and can somebody supply the rather
essential missing piece?
--
Lars
More information about the varnish-misc
mailing list