Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
memcache.inc_.patch | 1016 bytes | Jeremy |
Comments
Comment #1
catchbumping 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.