Public Member Functions | |
| sendStatusAndHeaders ($die) | |
| Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified), and returns a 304 if the client has a cached version. | |
| sendHeaders () | |
| Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified). | |
| isFresh () | |
| Determines whether the client has a fresh representation of the resource. | |
| etagMatch ($etag) | |
| Compares an etag with the resource's entity tag. | |
| getDuration ($type) | |
| Get the max-age or s-maxage cache control directive value. | |
| setDuration ($type, $time) | |
| Set max-age or s-maxage cache control directive value. | |
| freshFor ($time) | |
| Set max-age and the Expires header value. | |
| setCacheControlDirective ($type, $set) | |
| Set/unset Cache-Control directive. | |
| ccPublic ($set) | |
| Set/Unset Cache-Control public. | |
| ccNoCache ($set) | |
| Set/Unset Cache-Control no-cache. | |
| ccNoStore ($set) | |
| Set/Unset Cache-Control no-store. | |
| ccMustRevalidate ($set) | |
| Set/Unset Cache-Control must-revalidate. | |
| ccProxyRevalidate ($set) | |
| Set/Unset Cache-Control proxy-revalidate. | |
| etag ($value) | |
| Set value of the ETag header. | |
| weakEtag ($value) | |
| Set value of the ETag header to a weak value. | |
| lastModified ($value) | |
| Set value of the Last-Modified header. | |
| setLastModifiedFromFile ($file) | |
| Set value of the Last-Modified header using the last modification date of a file. | |
Static Public Member Functions | |
| static | isEtagWeak ($etag) |
| Determines if an entity tag is weak. | |
| static | etagValidator ($etag) |
| Returns the validator value of an entity tag. | |
| static | sendHeadersSpecifyingFreshness ($time) |
| Send cache headers. | |
| static | formatDate ($time) |
| Format a date in RFC 1123 date format. | |
Home page: http://larve.net/2006/08/php-http-caching/
Contributions from Kai Bolay
Definition at line 13 of file HttpCaching.php.
| HttpCaching::ccMustRevalidate | ( | $ | set | ) |
Set/Unset Cache-Control must-revalidate.
| $set | true or false to set or unset the parameter |
Definition at line 297 of file HttpCaching.php.
References setCacheControlDirective().
| HttpCaching::ccNoCache | ( | $ | set | ) |
Set/Unset Cache-Control no-cache.
| $set | true or false to set or unset the parameter |
Definition at line 281 of file HttpCaching.php.
References setCacheControlDirective().
| HttpCaching::ccNoStore | ( | $ | set | ) |
Set/Unset Cache-Control no-store.
| $set | true or false to set or unset the parameter |
Definition at line 289 of file HttpCaching.php.
References setCacheControlDirective().
| HttpCaching::ccProxyRevalidate | ( | $ | set | ) |
Set/Unset Cache-Control proxy-revalidate.
| $set | true or false to set or unset the parameter |
Definition at line 305 of file HttpCaching.php.
References setCacheControlDirective().
| HttpCaching::ccPublic | ( | $ | set | ) |
Set/Unset Cache-Control public.
| $set | true or false to set or unset the parameter |
Definition at line 273 of file HttpCaching.php.
References setCacheControlDirective().
| HttpCaching::etag | ( | $ | value | ) |
Set value of the ETag header.
| $value | Value (string) |
Definition at line 315 of file HttpCaching.php.
Referenced by weakEtag().
| HttpCaching::etagMatch | ( | $ | etag | ) |
Compares an etag with the resource's entity tag.
| $etag | Entity tag to compare |
Definition at line 157 of file HttpCaching.php.
Referenced by isFresh().
| static HttpCaching::etagValidator | ( | $ | etag | ) | [static] |
Returns the validator value of an entity tag.
| $etag | Entity tag |
Definition at line 190 of file HttpCaching.php.
| static HttpCaching::formatDate | ( | $ | time | ) | [static] |
Format a date in RFC 1123 date format.
| $time | Time since epoch in seconds |
Definition at line 369 of file HttpCaching.php.
| HttpCaching::freshFor | ( | $ | time | ) |
Set max-age and the Expires header value.
| $time | Duration as a positive number of seconds, a string for strtotime(), or a negative number to disable this directive |
| Throws | an exception for invalid values of $time |
Definition at line 249 of file HttpCaching.php.
References setDuration().
| HttpCaching::getDuration | ( | $ | type | ) |
Get the max-age or s-maxage cache control directive value.
| $type | "max-age" or "s-maxage" |
| Throws | an exception for invalid values of $type |
Definition at line 205 of file HttpCaching.php.
| static HttpCaching::isEtagWeak | ( | $ | etag | ) | [static] |
Determines if an entity tag is weak.
| $etag | Entity tag |
Definition at line 180 of file HttpCaching.php.
| HttpCaching::isFresh | ( | ) |
Determines whether the client has a fresh representation of the resource.
Definition at line 112 of file HttpCaching.php.
References etagMatch(), and lastModified().
Referenced by sendStatusAndHeaders().
| HttpCaching::lastModified | ( | $ | value | ) |
Set value of the Last-Modified header.
| $value | Unix timestamp |
Definition at line 334 of file HttpCaching.php.
Referenced by isFresh(), sendHeaders(), and setLastModifiedFromFile().
| HttpCaching::sendHeaders | ( | ) |
Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified).
Expires and Cache-Control are sent as set.
ETag is sent if set. Last-Modified is sent if set or if ETag isn't set, defaulting to the current time. Indeed, at least you of the two needs to be present for the response to be cacheable.
Definition at line 69 of file HttpCaching.php.
References lastModified().
Referenced by sendStatusAndHeaders().
| static HttpCaching::sendHeadersSpecifyingFreshness | ( | $ | time | ) | [static] |
Send cache headers.
| $time | Freshness duration |
Definition at line 357 of file HttpCaching.php.
| HttpCaching::sendStatusAndHeaders | ( | $ | die | ) |
Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified), and returns a 304 if the client has a cached version.
| $die | if set to true, the program terminates if a 304 is being sent, and if set to false, the call will return and the execution will continue |
The headers are sent with HttpCaching::sendHeaders.
Definition at line 44 of file HttpCaching.php.
References isFresh(), and sendHeaders().
| HttpCaching::setCacheControlDirective | ( | $ | type, | |
| $ | set | |||
| ) |
Set/unset Cache-Control directive.
| $type | Cache-Control directive (e.g. "public") | |
| $set | true or false to set or unset the parameter |
Definition at line 258 of file HttpCaching.php.
Referenced by ccMustRevalidate(), ccNoCache(), ccNoStore(), ccProxyRevalidate(), and ccPublic().
| HttpCaching::setDuration | ( | $ | type, | |
| $ | time | |||
| ) |
Set max-age or s-maxage cache control directive value.
| $type | "max-age" or "s-maxage" | |
| $time | Duration as a positive number of seconds, a string for strtotime(), or a negative number to disable this directive |
| Throws | an exception for invalid values of $time or $type |
Definition at line 220 of file HttpCaching.php.
Referenced by freshFor().
| HttpCaching::setLastModifiedFromFile | ( | $ | file | ) |
Set value of the Last-Modified header using the last modification date of a file.
| $file | File whose modification time will be used |
Definition at line 343 of file HttpCaching.php.
References lastModified().
| HttpCaching::weakEtag | ( | $ | value | ) |
Set value of the ETag header to a weak value.
| $value | Value (string) |
Definition at line 325 of file HttpCaching.php.
References etag().