lithium\action\Response::cache()

public method

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

void

Source

	public function cache($expires) {
		if ($expires === false) {
			$headers = [
				'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
				'Cache-Control' => [
					'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 = [
				'Expires' => gmdate('D, d M Y H:i:s', $expires) . ' GMT',
				'Cache-Control' => 'max-age=' . ($expires - time()),
				'Pragma' => 'cache'
			];
		}
		$this->headers($headers);
	}