Advanced Page Expiration

Component ID

2280899

Component name

Advanced Page Expiration

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

12848

Component created

Component changed

Component body

Advanced control of your cache-control header

Advanced Page Expiration addresses the use cases of needing certain pages on the site to expire faster than other pages. For example, using this module all pages on the site could be cached for 24 hours except for the homepage which could be cached for five minutes.

Advanced Page Expiration allows for better control of the Cache-Control header when using external caching servers such as Varnish. Every site with an external caching server that recognizes the use of a cache-control header to set TTL for cached pages such as Varnish and nginx should consider this module.

In Drupal this is controlled by the poorly named "Expiration of cached pages" dropdown on the performance configuration page. What Drupal isn't clear about is that this dropdown sets a cache-control header for Drupal when it responds to a request. This header is what tells caching servers like Varnish how long the URL should be kept in the cache.

Cache control header options

  • Increased cache lengths - The maximum amount of time for a cached item is 1 Day. This module allows up to 1 Year.
  • Exclude pages from caching - A list of pages that should not be cached can be defined. This sets the cache control header to no-cache.
  • Rules Integration - Using Rules more complex conditions beyond just path could be created to set the cache-control header. This is currently only supported for Drupal 7.x.
  • hook_ape_cache_expiration_alter() - This hook will allow complex custom logic to determine the cache expiration length.

Also, just to be clear this module only applies to external page caching, not Drupal's internal page cache.