How to purge / clear Varnish cache for a single URL

Varnish is a reverse web proxy accelerator that caches the HTTP contents. It can speed up requests by a factor of 500-1000 times. By caching and saving CPU time and database requests for content, varnish is able to server hundreds of consecutive requests per second.
In order to purge or clear Varnish cache, you can simply restart Varnish. This will clear the varnish cache.

/etc/varnish restart

or if you are using ‘services’ on your server, you can run the following on the command line

service varnish restart

In order to purge varnish cache for a specific URL, using CURL :


Running this command should provide an output like this :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    <title>200 Varnish cache has been purged for this object.</title>
    <h1>Error 200 Varnish cache has been purged for this object.</h1>
    <p>Varnish cache has been purged for this object.</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 1398586940</p>
    <p>Varnish cache server</p> <script type="text/javascript" defer src=""></script></body>

Clearing the varnish cache for a specific URL using varnishadm

To open the varnishadm console. use the following command to purge the URL :

varnishadm -T -S /etc/varnish/secret ban " == && req.url == /some/url/"