Assets
extends SiteAction
in package
Handle all the cacheing stuff and maybe return a file
Table of Contents
- $maxage : int
- $file : string
- $mtime : int
- $mtypes : array<, string>
- checketag() : bool
- Check an etag to see if we need to send the page again or not.
- checkmodtime() : bool
- Check a timestamp to see if we need to send the page again or not - overriding method in SiteAction
- checkRest() : array<, string>
- Validate the number of fields in the rest of the URL
- exists() : bool
- Returns true of the request would generate a page.
- handle() : string
- Handle access to things in assets
- ifmodcheck() : void
- Look to see if there are any IF... headers, and deal with them. Exit if a 304 or 412 is generated.
- lastmodified() : int
- Get a last modified time for the page
- makeetag() : string
- Make an etag - overrides the function in SiteAction
- makemaxage() : int
- Make a maximum age - overrides function in SiteAction
- makemod() : string
- Format a time suitable for Last-Modified header
- set304Cache() : void
- Set any cache headers that are wanted on a 304 response
- setCache() : void
- Set any cache headers that are wanted for a normal page delivery
- setCSP() : void
- Set up any CSP headers for a page
- etagmatched() : void
- We have a matched etag - check request method and send the appropriate header.
Properties
$maxage
protected
static int
$maxage
= 3600
- the default maxage for a page. This is a static because you can't have consts in a trait....
$file
private
string
$file
= ''
The file name
$mtime
private
int
$mtime
= 0
Last modified time for the file
$mtypes
private
static array<, string>
$mtypes
= ['' => 'text/plain', 'css' => 'text/css', 'js' => 'text/javascript', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'ico' => 'image/x-icon']
Mime type values
Methods
checketag()
Check an etag to see if we need to send the page again or not.
public
checketag(Context $context, string $tag) : bool
Parameters
- $context : Context
-
The context object for the site
- $tag : string
-
The etag value to check
Return values
bool —checkmodtime()
Check a timestamp to see if we need to send the page again or not - overriding method in SiteAction
public
checkmodtime(Context $context, string $time) : bool
Parameters
- $context : Context
-
The context object for the site
- $time : string
-
The time value to check
Tags
Return values
bool —checkRest()
Validate the number of fields in the rest of the URL
public
checkRest(array<, string> $rest, int $start, int $num[, array<, string> $format = [] ]) : array<, string>
Parameters
- $rest : array<, string>
- $start : int
-
The element to start at
- $num : int
-
The number of params required
- $format : array<, string> = []
-
Currently not used
Tags
Return values
array<, string> —exists()
Returns true of the request would generate a page.
public
exists(Context $context) : bool
This needs to be overridden if it is to be used. Currently returns TRUE, thus assuming that pages always exist....
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
bool —handle()
Handle access to things in assets
public
handle(Context $context) : string
You can rely on Apache to deal with these things normally, however if you really want to get cacheability to be complete you either have to go through hoops in the Apache config or you code it in here!
Parameters
- $context : Context
-
The context object for the site
Return values
string —A template name
ifmodcheck()
Look to see if there are any IF... headers, and deal with them. Exit if a 304 or 412 is generated.
public
ifmodcheck(Context $context) : void
Parameters
- $context : Context
Tags
Return values
void —lastmodified()
Get a last modified time for the page
public
lastmodified(Context $context) : int
By default this returns the current time. For pages that need to use this in anger, then this function may need to be overridden.
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
int —makeetag()
Make an etag - overrides the function in SiteAction
public
makeetag(Context $context) : string
Parameters
- $context : Context
-
The context object for the site
Return values
string —makemaxage()
Make a maximum age - overrides function in SiteAction
public
makemaxage(Context $context) : int
An hour for the most recent volume and a year for everything else
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
int —makemod()
Format a time suitable for Last-Modified header
public
makemod(int $time) : string
Parameters
- $time : int
-
The last modified time
Return values
string —set304Cache()
Set any cache headers that are wanted on a 304 response
public
set304Cache(Context $context) : void
Parameters
- $context : Context
-
The context object for the site
Tags
Return values
void —setCache()
Set any cache headers that are wanted for a normal page delivery
public
setCache(Context $context) : void
Parameters
- $context : Context
-
The context object
Tags
Return values
void —setCSP()
Set up any CSP headers for a page
public
setCSP() : void
There will be a basic set of default CSP permissions for the site to function, but individual pages may wish to extend or restrict these.
Tags
Return values
void —etagmatched()
We have a matched etag - check request method and send the appropriate header.
private
etagmatched(Context $context) : void
Does not return
Parameters
- $context : Context