Clear Varnish Cache from Drush

I you have a Drupal site and you are using the Varnish integration in your Drupal you can take advantage of the drush command to clear the varnish cache.

drush varnish-purge-all

The thing is that in certain situation this command won’t work as we expected since in order to flush everything this command will try to solve the base_path and the domain that is being used by varnish, but in many cases our sites will have a public address used with varnish a some private address for editorial use, without varnish or a light configured varnish, or will have different domains, if you are into a multisite environment and you run the command into the default site you won’t get what you are expecting.

An option is to set –uri parameter in the drush command, another option is to call to the function that will do the clearing directly with drush.

drush php-eval "varnish_purge('www.yoursite.com', '/');"

With that you are sure that will delete everything in varnish.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.