This document contains information for an outdated version (3.0) and may not be maintained any more. If some of your projects still use this version, consider upgrading as soon as possible.
By default, PHP add caching headers that make the page appear "purely dynamic".
This isn't usually appropriate for most sites, even ones that are updated reasonably frequently.
In particular, the default PHP cache-control settings prevent sites from appearing in the internet archive.
SilverStripe overrides the default settings with the following:
Last-Modifieddate is set to be most recent modification date of any database record queried in the generation of the page.
Expirydate is set by taking the age of the page and adding that to the current time.
Cache-Controlis set to
- Since a visitor cookie is set, the site won't be cached by proxies
- Ajax requests are never cached.
Overriding these defaults
- HTTP::set_cache_age()&version=3.0&module=framework) can be used to set the max-age component of the cache-control line, in seconds.
Set it to 0 to disable caching; the "no-cache" clause in
Pragmawill be included.
- HTTP::register_modification_date()&version=3.0&module=framework) can be used to set the modification date to something more recent than the default.
How it works:
- DataObject::__construct()&version=3.0&module=framework) calls HTTP::register_modification_date()&version=3.0&module=framework) whenever a record comes from the database
Controller::run()calls HTTP::add_cache_headers()&version=3.0&module=framework) before outputting the page