What this module does

This module allows the setting of "tags" to ease the burden of invalidating interconnected pages on a website using Varnish. Information about this strategy can be found at the Varnish site. It accomplishes this by having Rules actions that set headers and also trigger the Purge module to remove them.

Installation

  • Download and install this module along with Rules and Purge
  • Configure Varnish to respond to PURGE headers -- see the Varnish site for more information
  • Edit configuration to set hosts to remove tags on at admin/config/development/performance/varnish-tags
  • Select which entities to automatically tag and purge or configure Rules to set and remove tags

Additional integrations

  • Integrates with CTools Page Manager and Panelizer to allow creation of tags through their UI -- adding tags to variants will send them when those pages are rendered

Notes

  • Some entities that do not provide full URLs can cause issues when trying to purge. This has occurred with Search API entities; it is recommended that you disable these entity types at /admin/config/development/performance/varnish-tags/entities
  • If the site has a minimum cache period Drupal may cache the entity or page even though Varnish is cleared, this could cause subsequent requests to a page to receive a stale cached version from Drupal and then cache it in Drupal for a presumably longer duration; it is recommended to set minimum cache period to none.

An example of code that could be added to your default.vcl file to remove the tags is:

if (req.request == "PURGE") {
  ban("obj.http.X-Varnish-Tag ~ (?i)" + regsub(req.url, "^\/", "") + " && req.http.host ~ " + req.http.host);
  error 200 "Purged" ;
}

Thanks

Sponsored by Forum One Communications

Project information

Releases