Caching

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 \Support\SiteAction 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 class/support/siteaction.php .

No Caching

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:


    use \Support\NoCache;
            

Max Age

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 makemaxage

Setting Cache Headers

The method setCache can be altered to set up any special cache headers that a particualr page needs. The default behaviour is to call set304Cache 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.

ETags

Override 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 in \Support\SiteAction. The default is to return '', i.e. no ETag.

Existence

The exists returns a boolean indicating whether or not a page exists. The default return value is TRUE.

Last Modified

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.

Check ETag

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.