<div dir="ltr">


















<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">Using <b>BAN</b>, is it possible to invalidate a particular variant of a varnish cache?</span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">We use locale in http vary header to keep different variants of the cache, but the <b>BAN</b> configured is invalidating all the cache. <b><br></b></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><b><br></b></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><b>BAN configuration <br></b></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><b>


















</b></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">sub vcl_backend_response {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>set beresp.http.x-ban-locale =
bereq.http.X-BOLT-SITE-LOCALE;<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>set beresp.http.x-url = bereq.url;<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">}<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span> </span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">sub vcl_deliver {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>unset resp.http.x-ban-locale;<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>unset resp.http.x-url;<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">}<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span> </span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">sub vcl_recv {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>if (req.method == "BAN") {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>        </span>if(req.http.x-ban-regex) {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>            </span>ban("obj.http.x-ban-locale ==
" +req.http.X-BOLT-SITE-LOCALE +" && obj.http.x-url ~
"+req.http.x-ban-regex);<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>        </span>} else {<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>            </span>ban("obj.http.x-ban-locale ==
" +req.http.X-BOLT-SITE-LOCALE +" && obj.http.x-url ==
"+req.url);<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>        </span>}<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>        </span>return(synth(200, "Ban
Added"));<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span>    </span>}<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">}<span></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span> </span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><b><span style="font-size:11pt"><span>CURL command to add the BAN</span></span></b></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span> <br></span></span></p>

<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt">curl -v -XBAN -H
'x-ban-regex:^/boltapi/v1/ads*(\?.*)*$' -H 'X-BOLT-SITE-LOCALE:en_ZA' -H
'Vary:en_ZA' {hostname}:{port}<span></span></span></p>





<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:"Calibri",sans-serif"><span style="font-size:11pt"><span></span></span></p>





</div>