varnish vcl purging cache selectively

Amit picture Amit · Apr 7, 2012 · Viewed 7k times · Source

So i am using varnish for the first time. i have spent quite some time reading on how it works, but i am unable to figure out how do i selectively purge the cache.

like say i have a url like this

/?account=123&url=google.com

and another like

/?account=123&url=stackoverflow.com

I need to purge the cache where account=123.

I can only figure out that issuing purge on

/?account=123&url=stackoverflow.com

will only purge the cache where the url matches the incoming url with PURGE method.

Any help is appreciated.

Answer

Amit picture Amit · Jun 5, 2012

So this is what works. In varnish 3 selective purge is called ban. so you need to use

ban("obj.http.x-url ~ " + req.url);