|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| __construct ($spec) | |
| getHeaders () | |
| setContentLength ($bytes) | |
| sendHeaders () | |
Static Public Member Functions | |
| static | check ($lastModifiedTime=null, $isPublic=false, $options=array()) |
| static | gmtDate ($time) |
Data Fields | |
| $cacheIsValid = null | |
Protected Member Functions | |
| _setEtag ($hash, $scope) | |
| _setLastModified ($time) | |
| _isCacheValid () | |
| resourceMatchedEtag () | |
| normalizeEtag ($etag) | |
| resourceNotModified () | |
Protected Attributes | |
| $_headers = array() | |
| $_lmTime = null | |
| $_etag = null | |
| $_stripEtag = false | |
Definition at line 63 of file ConditionalGet.php.
| __construct | ( | $ | spec | ) |
| array | $spec | options |
'isPublic': (bool) if true, the Cache-Control header will contain "public", allowing proxies to cache the content. Otherwise "private" will be sent, allowing only browser caching. (default false)
'lastModifiedTime': (int) if given, both ETag AND Last-Modified headers will be sent with content. This is recommended.
'encoding': (string) if set, the header "Vary: Accept-Encoding" will always be sent and a truncated version of the encoding will be appended to the ETag. E.g. "pub123456;gz". This will also trigger a more lenient checking of the client's If-None-Match header, as the encoding portion of the ETag will be stripped before comparison.
'contentHash': (string) if given, only the ETag header can be sent with content (only HTTP1.1 clients can conditionally GET). The given string should be short with no quote characters and always change when the resource changes (recommend md5()). This is not needed/used if lastModifiedTime is given.
'eTag': (string) if given, this will be used as the ETag header rather than values based on lastModifiedTime or contentHash. Also the encoding string will not be appended to the given value as described above.
'invalidate': (bool) if true, the client cache will be considered invalid without testing. Effectively this disables conditional GET. (default false)
'maxAge': (int) if given, this will set the Cache-Control max-age in seconds, and also set the Expires header to the equivalent GMT date. After the max-age period has passed, the browser will again send a conditional GET to revalidate its cache.
Definition at line 112 of file ConditionalGet.php.

| _isCacheValid | ( | ) | [protected] |
Determine validity of client cache and queue 304 header if valid
Definition at line 286 of file ConditionalGet.php.


| _setEtag | ( | $ | hash, |
| $ | scope | ||
| ) | [protected] |
| _setLastModified | ( | $ | time | ) | [protected] |
Definition at line 277 of file ConditionalGet.php.


Exit if the client's cache is valid for this resource
This is a convenience method for common use of the class
| int | $lastModifiedTime | if given, both ETag AND Last-Modified headers will be sent with content. This is recommended. |
| bool | $isPublic | (default false) if true, the Cache-Control header will contain "public", allowing proxies to cache the content. Otherwise "private" will be sent, allowing only browser caching. |
| array | $options | (default empty) additional options for constructor |
Definition at line 236 of file ConditionalGet.php.
| getHeaders | ( | ) |
Get array of output headers to be sent
In the case of 304 responses, this array will only contain the response code header: array('_responseCode' => 'HTTP/1.0 304 Not Modified')
Otherwise something like: array( 'Cache-Control' => 'max-age=0, public' ,'ETag' => '"foobar"' )
Definition at line 176 of file ConditionalGet.php.
| static gmtDate | ( | $ | time | ) | [static] |
Get a GMT formatted date for use in HTTP headers
header('Expires: ' . HTTP_ConditionalGet::gmtdate($time));
| int | $time | unix timestamp |
Definition at line 261 of file ConditionalGet.php.

| normalizeEtag | ( | $ | etag | ) | [protected] |
| resourceMatchedEtag | ( | ) | [protected] |
Definition at line 301 of file ConditionalGet.php.


| resourceNotModified | ( | ) | [protected] |
Definition at line 330 of file ConditionalGet.php.


| sendHeaders | ( | ) |
Send headers
Note this doesn't "clear" the headers. Calling sendHeaders() will call header() again (but probably have not effect) and getHeaders() will still return the headers.
Definition at line 208 of file ConditionalGet.php.
| setContentLength | ( | $ | bytes | ) |
Set the Content-Length header in bytes
With most PHP configs, as long as you don't flush() output, this method is not needed and PHP will buffer all output and set Content-Length for you. Otherwise you'll want to call this to let the client know up front.
| int | $bytes |
Definition at line 192 of file ConditionalGet.php.
$_etag = null [protected] |
Definition at line 268 of file ConditionalGet.php.
$_headers = array() [protected] |
Definition at line 266 of file ConditionalGet.php.
$_lmTime = null [protected] |
Definition at line 267 of file ConditionalGet.php.
$_stripEtag = false [protected] |
Definition at line 269 of file ConditionalGet.php.
| $cacheIsValid = null |
Definition at line 73 of file ConditionalGet.php.