Mailing List Archive

Labels and purge scope
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
Re: Labels and purge scope [ In reply to ]
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@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@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
Re: Labels and purge scope [ In reply to ]
Thank you for this confirmation !

Now I know this is the same cache, I will move the ban block in the main
VCL !

Thanks again !

Regards,

--

Adrien Bigot

Le 19/12/2019 à 16:14, Guillaume Quintard a écrit :
> 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@smile.fr
> <mailto:adrien.bigot@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
> <http://front.mydomain.com>") {
>       return (vcl(l_varnish_fronts));
>     }
>     if (req.http.host == "api.mydomain.com
> <http://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
> <http://front.mydomain.com>' --header 'Cache-BanExpression:
> obj.http.Cache-Tags-TeamCompetitionReference ~ (^|,)6847(,|$)'  
> http://myVarnishIP
> curl -XBAN --header 'Host: api.mydomain.com
> <http://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@varnish-cache.org <mailto:varnish-misc@varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>