SilverStripe\ControllerPolicy\Policies\CachingPolicy
A rewrite of the default SilverStripe behaviour allowing more customisation. Consuming code can provide its own callbacks for providing custom cacheAge, vary and timestamp parameters.
See PageControlledPolicy as an example implementation of such customisation that applies on top of default.
Extends HTTP to get access to globals describing the Last-Modified and Etag data.
Synopsis
class CachingPolicy
extends HTTP
implements
ControllerPolicy
{
- // members
- private static bool $disable_cache_age_in_dev = true;
- protected integer $cacheAge = 0;
- protected string $vary = '';
- // methods
- public $this setCacheAge()
- public int getCacheAge()
- public $this setVary()
- public string getVary()
- public void applyToResponse()
Hierarchy
Members
private
- $disable_cache_age_in_dev
—
SilverStripe\ControllerPolicy\Policies\bool
Whether to disable the cache age (set to zero) in dev environments
protected
- $cacheAge
—
int
Max-age seconds to cache for if configuration not available from the originator. - $vary
—
string
Vary string to add if configuration is not available from the originator.
Methods
public
- applyToResponse()
- getCacheAge() — Get the cache age
- getVary() — Get the "vary" content header
- setCacheAge() — Set the cache age
- setVary() — Set the "vary" content header