public cache ( mixed $expires ) : void | ||
$expires | mixed | 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. |
return | void |
public function cache($expires)
{
if ($expires === false) {
$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');
} else {
$expires = is_int($expires) ? $expires : strtotime($expires);
$headers = array('Expires' => gmdate('D, d M Y H:i:s', $expires) . ' GMT', 'Cache-Control' => 'max-age=' . ($expires - time()), 'Pragma' => 'cache');
}
$this->headers($headers);
}
*/ $backend = Libraries::get('li3_backend', 'urlPrefix'); $backend || ($backend = 'backend'); /** * Enable access to assets from installed libraries * This route expect all `lithium` libraries prefixed with `li3_` * * For example route `'/assets/backend/css/bootstrap.css'` is equivalent to: * `'/assets/li3_backend/css/bootstrap.css'` and will look for assets in library `webroot` dir. * * To speed up your application you can copy any asset to your public webroot. Just create same * directory structure as url and your asset will be loaded properly. */ Router::connect('/assets/{:library}/{:args}', array(), function ($request) { $file = Media::webroot('li3_' . $request->params['library']); $file .= '/' . join('/', $request->params['args']); if (file_exists($file)) { $info = pathinfo($file); $media = Media::type($info['extension']); $content = (array) $media['content']; $response = new Response(array('headers' => array('Content-type' => reset($content)), 'body' => file_get_contents($file))); $response->cache('+1 hour'); return $response; } throw new \lithium\action\DispatchException(); }); /** * Backend routing * `backend` prefix is prepended to `action` name. */ Router::connect('/' . $backend . '/{:args}', array('backend' => true), array('continue' => true));