Labels and purge scope

Guillaume Quintard guillaume at varnish-software.com
Thu Dec 19 15:14:16 UTC 2019


Hi,

Yes, labels are going to access the same cache , exactly like a reloaded
vcl is going to use the same cache as the vcl it replaced.

So, sending one request on any domain is going to work, but wouldn't it be
more straightforward to just have the ban block in the main vcl, before you
dispatch the request to a sub vcl?

Cheers,


On Thu, Dec 19, 2019, 15:07 Adrien Bigot <adrien.bigot at smile.fr> wrote:

> Hello,
>
> I plan to use labels on a Varnish stack in front of multiple backends.
> I have a question about ban with multiple labels.
>
> My main.vcl will route requests in function of Host header for example
> like this :
>
> if (req.http.host == "front.mydomain.com") {
>       return (vcl(l_varnish_fronts));
>     }
>     if (req.http.host == "api.mydomain.com") {
>       return (vcl(l_varnish_api));
>     }
>
>
> When we want to ban objects we do it with a HTTP BAN method on each
> varnish server. Varnish handle it the BAN request like that  in each
> label's VCL file :
> sub vcl_recv {
>         if (req.method == "BAN") {
>
>         if (req.http.Cache-BanExpression) {
>             ban(req.http.Cache-BanExpression);
>         }
>         return (synth(200, "Banned"));
> }
>
>
> My question is if I want to purge contents like this :
>
> curl -XBAN --header 'Cache-BanExpression:
> obj.http.Cache-Tags-TeamCompetitionReference ~ (^|,)6847(,|$)'
> http://myVarnishIP
>
> Will them be banned for all my Labels (if I include the proper vcl code in
> main.vcl), or do I have to make a request for each label like :
> curl -XBAN --header 'Host: front.mydomain.com' --header
> 'Cache-BanExpression: obj.http.Cache-Tags-TeamCompetitionReference ~
> (^|,)6847(,|$)'   http://myVarnishIP
> curl -XBAN --header 'Host: api.mydomain.com'    --header
> 'Cache-BanExpression: obj.http.Cache-Tags-TeamCompetitionReference ~
> (^|,)6847(,|$)'   http://myVarnishIP
>
>
> In fact, I want to know if the cache is mutualized between labels ? If
> yes, is a solution exists to purge contents in all labels without sending
> multiple BAN requests ?
>
> Thanks in advance.
>
> Best regards,
>
> --
>
> Adrien Bigot
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20191219/395be9cb/attachment.html>


More information about the varnish-misc mailing list