Drupal - How to clear varnish cache using drush? I'm on acquia cloud dev account
With Acquia Cloud API v1 Drush commands
On Acquia Could API v1 the command is ac-domain-purge
. Here is a snippet from the drush help available from the Acquia box.
$ drush help ac-domain-purge
Purge a domain from the Varnish cache.
Arguments:
domain Domain name.
Options:
--username Acquia Cloud API username
--password Acquia Cloud API password
--acapi-conf-path Acquia Cloud API config files location. If not specified config will be loaded from $HOME/.drush
--caller Acquia Cloud API caller name. Default is the current username.
--endpoint Acquia Cloud API endpoint URL.
--cainfo Path to a file containing the SSL certificates needed to verify the ac-api-endpoint.
--format Format to output the object. Use "print_r" for print_r, "export" for var_export, and "json" for JSON. If not provided, the output is printed in a human-readable format.
Additionally, if you want to do this programmatically without drush, Acquia have an API endpoint for clearing the varnish cache.
Note that the drush commands only work with Acquia Cloud API version 1, which is EOL in 2020.
With Acquia Cloud API v2 requests
Acquia Cloud API v2 is json-api based, and the following API v1 to v2 migration document explains the URL request homologue that replaces each v1 drush command. In this case:
The V1 drush API command ac-domain-purge
becomes one of either:
POST /environments/{environmentId}/domains/actions/clear-varnish
To clear the Varnish cache for all domains used in an environment (eg both the internal appname.prod.acquia-sites.com domain, as well as your site's public domain.
POST /environments/{environmentId}/domains/{domain}/actions/clear-varnish
To clear the Varnish cache for a single specific domain.
See the Acquia Cloud API v2 documentation reference for additional information.
There is also a module for that called appropriately "Acquia Purge". Works perfectly. Details from project page:
The Acquia Purge module allows Drupal sites hosted on Acquia Cloud to automatically purge (wipe) pages from their Varnish powered load balancers, as soon as content actually changed. The higher Drupal's "expiration of cached pages"-setting (TTL) is configured the more your site will be served directly off your load balancers. This effectively increases the efficiency of your site and lowers hardware costs, leaving more resources for back-end traffic. In most scenarios the module offers a full turn-key experience without requiring any technical configuration.
I know this doesn't answer the actual question, but its a really easy way to purge varnish cache on acquia cloud using the rules and cache expiration module as dependencies.