BAN variant of varnish cache
Santosh Abraham
santoshab000 at gmail.com
Mon Oct 14 14:13:23 UTC 2019
Using *BAN*, is it possible to invalidate a particular variant of a varnish
cache?
We use locale in http vary header to keep different variants of the cache,
but the *BAN* configured is invalidating all the cache.
*BAN configuration *
sub vcl_backend_response {
set beresp.http.x-ban-locale = bereq.http.X-BOLT-SITE-LOCALE;
set beresp.http.x-url = bereq.url;
}
sub vcl_deliver {
unset resp.http.x-ban-locale;
unset resp.http.x-url;
}
sub vcl_recv {
if (req.method == "BAN") {
if(req.http.x-ban-regex) {
ban("obj.http.x-ban-locale == " +req.http.X-BOLT-SITE-LOCALE +"
&& obj.http.x-url ~ "+req.http.x-ban-regex);
} else {
ban("obj.http.x-ban-locale == " +req.http.X-BOLT-SITE-LOCALE +"
&& obj.http.x-url == "+req.url);
}
return(synth(200, "Ban Added"));
}
}
*CURL command to add the BAN*
curl -v -XBAN -H 'x-ban-regex:^/boltapi/v1/ads*(\?.*)*$' -H
'X-BOLT-SITE-LOCALE:en_ZA' -H 'Vary:en_ZA' {hostname}:{port}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20191014/22edbad0/attachment.html>
More information about the varnish-dev
mailing list