/** * Sets the various cache headers. Auto unsets 'Last-Modified' * if $expires_offset is falsy. * * @param int|bool $expires_offset Time in seconds from now to cache. * Pass 0 or false for no cache. * @return $this */ public function setCacheHeaders($expires_offset = 86400) { $headers = Util::buildCacheHeaders($expires_offset); // empty("0") is false negative if (empty($expires_offset) || '0' === $expires_offset) { unset($this->headers['Last-Modified']); } $this->setHeaders($headers); return $this; }
/** * Returns an associative array of cache headers suitable for use in header(). * * Returns the 'Cache-Control', 'Expires', and 'Pragma' headers given the * expiration offset in seconds (from current time). If '0' or a value which * evaluates to empty is given, returns "no-cache" headers, with Cache-Control * set to 'no-cache, must-revalidate, max-age=0', 'Expires' set to a date in the * past, and 'Pragma' set to 'no-cache'. * * @param int $expires_offset Expiration in seconds from now. * @return array Associative array of cache headers. */ function http_build_cache_headers($expires_offset = 86400) { return Util::buildCacheHeaders($expires_offset); }