troubleshooting Varnish purges vs bans

Miguel González miguel_3_gonzalez at yahoo.es
Wed Aug 16 12:13:57 CEST 2017


I have found out how to make to work varnish http purge plugin with
Varnish 4.x in this article (funny it´s on the Varnish blog)

https://info.varnish-software.com/blog/step-step-speed-wordpress-varnish-software?success=true



I have to say If I added the snippet mentioned:

if (req.http.X-Purge-Method == "regex") {

ban("req.url ~ " + req.url + " && req.http.host ~ " + req.http.host);

return (synth(200, "Banned."));

} else {

return (purge);

}

It didn´t work out of the box. I got the following VCL_error:

- VCL_Error ban(): Expected && between conditions, found "&&"

I had to change it to:

if (req.http.X-Purge-Method == "regex") {

ban("req.url ~ " + req.url + " && req.http.host ~ " + req.http.host);

return (synth(200, "Banned."));

} else {

return (purge);

}

So maybe for other users using Wordpress with Varnish it might be useful

Regards,

Miguel


On 08/15/17 1:07 PM, Miguel González wrote:
> On 08/11/17 12:22 PM, Dridi Boukelmoune wrote:
>>>  The Wordpress plugin is supposed to clean the whole cache for a website
>>> when clicking on a button saying "Clear cache".
>>>
>>>  You say from the varnishlog excerpt I sent that´s not the correct way
>>> of doing so, or apparently what is logged by varnish is not a correct purge.
>>>
>>>  So how do I tell the developer (or do it myself) to correct the code so
>>> the whole cache for a given website is purged?.
>>
>> Use the ban() function in your VCL in this case.
>>
>> Dridi
>>
> 
> I currently have in default.vcl this:
> 
>         # Allow purging from ACL
>         if (req.method == "PURGE") {
>                 # If not allowed then a error 405 is returned
>                 if (!client.ip ~ purge) {
>                         return(synth(405, "This IP is not allowed to
> send PURGE requests."));
>                 }
>                 # If allowed, do a cache_lookup -> vlc_hit() or vlc_miss()
>                 return (purge);
>         }
> 
> 
> What do I have to change to use BAN? If I run ban at command line they
> seem to work.
> 
> Do I need to change the Wordpress plugin to send BAN requests?
> 
> Thanks!
> 
> Miguel
> 




More information about the varnish-misc mailing list