Last updated January 2, 2015. Created on December 17, 2013.
Edited by znerol. Log in to edit this page.

Many actions on a Drupal site trigger a flush of the entire page cache, including but not limited to (list courtesy of Brian K. Osborne):

  • A node is created/edited/deleted
  • A block is created/edited/deleted
  • A comment is created/edited/deleted
  • A vote is registered in a poll
  • User profile fields are manipulated
  • System theme settings are changed
  • Taxonomy terms/vocabularies are manipulated
  • Permissions for roles are changed
  • Cron is run

Therefore when site content changes frequently, the cache hit rate will suffer. In order to prevent frequent flushes, a Minimum cache lifetime can be specified in Administration » Configuration » Development » Performance. However when this setting is too high, outdated content is served to users, which may not be acceptible under certain circumstances.

Using the Cache Expiration module it is possible to automatically remove a selected set of pages from the cache whenever content is modified. This allows for high Minimum cache lifetime values without risking that stale versions of important content is served to users.

Configure Cache Expiration

  1. Install the Cache Expiration module.
  2. Enable the Authcache Builtin Cache Expiration vX module (where X is either 1 or 2 matching the version of the installed Cache Expiration module).
  3. When using Cache Expiration 1.x, navigate to Administration » Configuration » Development » Performance » Cache Expiration and uncheck the option Include base URL in expires. Then save the configuration.
    Settings for Cache Expiration 7.x-1.x
  4. When using Cache Expiration 2.x, navigate to Administration » Configuration » System » Cache Expiration and set the implementation to External expiration. Adapt the rest of the settings to your needs and finally save the configuration.
    Settings for Cache Expiration 7.x-2.x
  5. Then go to Administration » Configuration » Development » Performance and max out the Minimum cache lifetime.
    Performance settings, max out minimum cache lifetime

Note that with this settings the whole page cache is still flushed completely once a day. But only selected pages will be removed from the cache when content is updated or a comment is posted.

The Expire Cache module comes with Rules integration. Therefore the expiration logic can be extended in many ways. However remember to always pass internal paths to the expire-action, the Cache Expiration integration for Authcache Builtin Storage Backend does not work with full URLs.

Notes

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.