The framework allows you control the cache settings for pages that are instantiated using a PHP object — at the moment you cannot control the settings for template only pages.
Every page object extends
\Framework\SiteAction which provides
several utility functions available to all pages. It also uses the trait
which is available for you to edit — you can add any new functions you want all pages to have access to here. However, it also allows
you to configure the default caching behaviour for your pages, and offers a set of methods that individual page objects can override
if they want something other than the default. You can see the source for the trait at
One of the commonest things you might need is to have a pge whose results are not cached. You can achieve this by using the trait
\Support\NoCache in your page class:
Change the value of the private static variable
$maxage to set the default maximum age for a page in seconds.
The default value is 36000 = 1 hour. To change the default the maximum age for a specific page, you need to override the method
Setting Cache Headers
setCache can be altered to
set up any special cache headers that a particualr page needs. The default behaviour is to call
which is used to set up the headers when a 304 response is generated. It too can be modified if you want
different headers when generating a 304.
makeetag when you
want to generate ETag values for a particular page. Or if you want to generate ETags for all pages then edit the version
\Support\SiteAction. The default is to return '', i.e. no ETag.
exists returns a boolean indicating
whether or not a page exists. The default return value is TRUE.
lastmodified returns a time value
to be used for a last modified time for the page. The default is to return the current time. Last Modified headers are often
not used these days though — the Framework does not generate one at the moment.
Check Modified Time
checkmodtime returns a boolean indicating
whether the time passed in to the function is the same as the current modification time. The default value is FALSE which means that pages
will be sent again. If you are generating ETags then you need to implement this function.
checketag checks to see if the ETag that has
been passed in on the request is the same as the one for the page. Whether or not you need to override this depends
on how you generate your ETag values.