Invalidating Varnish automatically with the Dropsolid Purge module¶
Your environment runs Varnish in front of your Drupal application. You can always clear the whole cache by hand, but for a Drupal site you usually want the cache to invalidate itself the moment content changes, and only for the pages that were affected. The Dropsolid Purge module does exactly that: it connects Drupal's cache-tag system to Varnish, so editing a node, term or menu clears just the cached pages that reference it, across every load balancer in front of your environment.
This is different from the manual "Clear Varnish" action, which empties the entire cache in one go. See Clearing your application's Varnish cache for that.
What the module does¶
- Invalidates Varnish by cache tag, so only the pages affected by a change are cleared instead of the whole site.
- Supports a full "everything" invalidation for the cases where you do want to clear all of it.
- Works across multiple load balancers.
- Scopes invalidation to your site with the
X-Dropsolid-Siteheader, so sites that share a Varnish never clear each other's cache.
Before you start¶
- A Drupal site running on your environment, using Varnish. (For how Varnish decides what to cache, see Controlling if and how long Varnish caches your pages.)
- The Varnish port for your environment (see "Find your Varnish port" below). The IP is
127.0.0.1.
Install the module¶
Install Dropsolid Purge the same way you install any other Drupal module. If you need a refresher, follow Drupal's own guide: Installing modules. With Composer that is:
composer require drupal/dropsolid_purge
Then enable it from the Extend screen or with drush en dropsolid_purge.
Configure it¶
The configuration steps (adding the purger at /admin/config/development/performance/purge and the settings.php block) are documented in the module's README. Follow those instructions there so you are always working from the current version: Dropsolid Purge on Drupal.org.
Two things to keep in mind while you follow the README:
- We recommend enabling both the cron and the late runtime purge processors for the fastest invalidation.
- In the load balancer configuration the IP is
127.0.0.1, which matches the README example. The one value you set per environment is the port (see "Find your Varnish port" below). In the rare cases where your environment uses a different IP, we tell you through the support desk.
Find your Varnish port¶
The port for the load balancer configuration comes from your own environment:
- Open your project in the platform and go to the environment you are configuring.
- Open the Services tab; the Varnish info is listed there.
- Use the port shown in the load balancer entry. Keep the IP at
127.0.0.1unless we have told you otherwise via the support desk.
Related¶
- Controlling if and how long Varnish caches your pages: control what gets cached and for how long.
- Clearing your application's Varnish cache: clear the whole cache by hand when you need to.