How to force Varnish to update cache contents

Every freistilbox cluster on our managed hosting platform has its own Varnish proxy cache. This cache stores content according to the HTTP headers that came with it. When the cache lifetime of a specific content object expires, Varnish will remove it from its cache store and request an update from your web application.

Cache invalidation using the Drupal Purge module

In order to let your Drupal application delete stale cache content, freistilbox supports the Purge module in conjunction with the Varnish Purger module.

The Varnish Purger module allows invalidating whole sets of cache objects at once by using “Cache Tags”. This method uses the Cache-Tags HTTP header to label content with one or more tags. All content with a certain tag can then be removed from the cache using a BAN request for this tag.

Configure the Varnish Purger module using the following details:

  • Hostname: (use your own cluster ID followed by a “v” for Varnish, for example
  • Port: 80
  • Path: ‘/`
  • Request method: BAN
  • Scheme: http

Also make sure that the Varnish Purger Tags submodule is configured like this:

  • Header: Cache-Tags
  • Value: [invalidation:expression]

Manual cache invalidation

To manually remove a certain content object from the cache, you can send a PURGE request with its URL from the command line:

curl -X PURGE http://my.dom.ain/path/to/the/content

This command will remove the object referenced by the URL from the cache.