Cache invalidation with regex

Alexandre infos at opendoc.net
Fri Dec 6 16:12:13 CET 2013


Hi,
I found a solution using directly varnishadm. I wanted to invalidate an 
entire url :

Exemple :

---
/image.php?var1=1&var2=1&var3=1
/image.php?var1=1&var2=2&var3=2
/image.php?var1=1&var3=1&var3=3
---

With this command :

---
varnishadm "ban.url var=1"
---

I can invalidate the cache of 3 url.

thx Cosimo.

Alex.

On 29/11/13 14:18, Alexandre wrote:
> Thank you very much. This is exactly what I want. I'll try to test the
> script in the day.
>
> Good day.
>
> Alex.
>
> On 29/11/13 13:49, Cosimo Streppone wrote:
>> On 11/29/2013 11:01 AM, Geoff Simmons wrote:
>>>
>>> On 11/28/2013 06:29 PM, Alexandre wrote:
>>>>
>>>> I will wish to invalidate my cache using a regex.
>>>>
>>>> example: ^/image.php?a=1&b=2*
>>>>
>>>> I would like to disable all url starting with ^/image.php?a=1&b=2
>>>>
>>>> Do you have an idea for my problem?
>>>
>>> The '*' in a regular expression is not like a file glob, it means that
>>> the character before it, in your case the '2', can appear 0 or more
>>> times.
>>>
>>> So your regex matches anything starting with:
>>>
>>> /image.php?a=1&b=
>>
>> I made a simple shell script wrapper to the varnish admin.
>> It is available here:
>>
>> https://gist.github.com/cosimo/890217
>>
>> If you run it with:
>>
>>    $ ./purge-cache.sh -h
>>
>> it will show some usage instructions.
>> In particular:
>>
>>    $ ./purge-cache -r '^/image\.php\?a=1&b=2.*'
>>
>> should purge the URLs you asked for.
>>
>> It worked for me at least, and I added
>> to my varnish puppet module, to always have it available
>> alongside reload-vcl etc...
>>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list