The goal of the attached patch is to make it possible to control the minimum cache lifetime for your site on a per-path (URL) basis.

With the patch applied, granular page cache lifetimes are configured by adding a pagecache_lifetime array to the $conf array in the format PATH_REGEX => SECONDS. For example:

        $conf = array(
          'pagecache_lifetime' => array(
            '&^http://www\.sample\.com/blogs.*&' => 86400,
            '&^http://www\.sample\.com/tracker.*&' => 1800,
            '&^http://www\.sample\.com/$&' => 60,
          ),
        );

In this example, http://www.sample.com will be cached for 60 seconds. Any page starting with http://www.sample.com/blogs will be cached for 1 day. And any page starting with http://www.sample.com/tracker will be cached for 30 minutes.

Writing path rules:

  • order is important: the first match is what is used.
  • the patch uses raw regular expressions. "." matches any single character. ".*" matches all characters. "^" signifies the start of the url, and "$" signifies the end.
  • if no path rule matches, then the default minimum cache lifetime is used as is set by Drupal's standard admin interface.
  • you can completely disable the page cache for paths by specifying a cache_lifetime of 0.
  • The minimum cache lifetime is specified in seconds.
CommentFileSizeAuthor
memcache.inc_.patch1016 bytesJeremy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs work

bumping to 7.x. This would be handy, would be good to possibly merge with the per-bin code from #186638: Add a 'keep until' column for cache tables as well.