Clearing Varnish Cache without Restart

There has been a number of times when I’ve needed to clear the Varnish caching server’s cache, but had no clue how to do this. This resulted in me restarting Varnish, which really wasn’t needed.

The easiest way to clear the Varnish cache (without restarting) is by using the varnishadm command line tool:

varnishadm -T 127.0.0.1:6082 url.purge .

The man page for varnishd shows a number of command which can be used with varnishadm , but the one we need is url.purge:

url.purge regexp
     Immediately invalidate all documents whos URL matches the specified regular expres-
     sion.