Varnish caching protects your application and provides content to users. Sometimes it continues to provide content to users even if your application is down for a short period. In certain scenarios, you need to remove content faster than the standard Varnish timeout for your application. Acquia recommends that you use the Acquia Purge (recommended) method to clear your Varnish cache in certain situations where you need to modify content faster than the standard Varnish timeout for your application.
Alternatively, you can use the Command line method to manually purge content from Varnish cache through drush
. However, it is not a recommended method.
Acquia Purge (recommended)
The Acquia Purge module is the recommended method to clear specific pages or all pages from Varnish cache. For information about how to install and configure this module, visit Installing Acquia Purge.
Command line
If you choose to use this alternative method, read the following considerations before you begin:
Varnish stores caches for each domain individually. If you configure multiple domains, such as
www.mysite.com
andcms.mysite.com
, to reference the same application, you must make individualdrush
requests for each domain referencing the page that you want to clear from Varnish cache.When you run the purge commands on this page, it does not invalidate Drupal caches. If Drupal cache objects are not scheduled for purging from the cache and Memcache, purging the Varnish cache does not make any difference. As a result, you must clear the relevant cache id (CID) for the cache objects that you want to purge first.
Do not clear all Drupal caches because a complete cache clear might negatively affect the performance of your application while caches are rebuilt.
For more information about the different layers of caching, visit Caching overview.
Manually purging content through drush
To manually purge a path through drush
, run the following command:
drush p:invalidate
The
drush p:invalidate
command invalidates an item before it goes through the queue and takestype
as the argument. This argument decides the type of invalidation to be performed, for example: tag, path, or url.
This command has the following aliases:
- pinv
- p-invalidate
It has the following option:
--format[=FORMAT] [default: string]
It has the following Global options:
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-y, --yes Auto-accept the default for all user prompts. Equivalent to --no-interaction.
-l, --uri=URI A base URL for building links and selecting a multi-site. Defaults to https://default.
The following example clears URLs tagged with "node:1" from external caching platforms.
drush p:invalidate tag node:1
The following example clears "http://www.drupal.org/" from external caching platforms.
drush p:invalidate url http://www.drupal.org/