Extends
lithium\net\http\Response
Controls how or whether the client browser and web proxies should cache this response.
Parameters
- mixed $expires This can be a Unix timestamp indicating when the page expires, or a string indicating the relative time offset that a page should expire, i.e. `"+5 hours". Finally, `$expires` can be set to `false` to completely disable browser or proxy caching.
Returns
voidSource
public function cache($expires) {
if ($expires === false) {
return $this->headers(array(
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control' => array(
'no-store, no-cache, must-revalidate',
'post-check=0, pre-check=0',
'max-age=0'
),
'Pragma' => 'no-cache'
));
}
$expires = is_int($expires) ? $expires : strtotime($expires);
return $this->headers(array(
'Expires' => gmdate('D, d M Y H:i:s', $expires) . ' GMT',
'Cache-Control' => 'max-age=' . ($expires - time()),
'Pragma' => 'cache'
));
}