Source for file Cache.php
Documentation is available at Cache.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Wolfram Kriesing <wk@visionp.de> |
// | Michael Wallner <mike@php.net> |
// +----------------------------------------------------------------------+
// $Id: Cache.php,v 1.8 2004/06/12 21:13:49 mike Exp $
require_once 'HTTP/Header.php';
* This package provides methods to easier handle caching of HTTP pages. That
* means that the pages can be cached at the client (user agent or browser) and
* your application only needs to send "hey client you already have the pages".
* Which is done by sending the HTTP-Status "304 Not Modified", so that your
* application load and the network traffic can be reduced, since you only need
* to send the complete page once. This is really an advantage e.g. for
* generated style sheets, or simply pages that do only change rarely.
* @version $Revision: 1.8 $
* Set the amount of time to cache.
* @return object HTTP_Header_Cache
if ($expires && !$this->isOlderThan($expires, $unit)) {
* Returns the unix timestamp of the If-Modified-Since HTTP header or the
* current time if the header was not sent by the client.
* @return int unix timestamp
if (isset ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
return strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
* You can call it like this:
* $httpCache->isOlderThan(1, 'day');
* $httpCache->isOlderThan(47, 'days');
* $httpCache->isOlderThan(1, 'week');
* $httpCache->isOlderThan(3, 'weeks');
* $httpCache->isOlderThan(1, 'hour');
* $httpCache->isOlderThan(5, 'hours');
* $httpCache->isOlderThan(1, 'minute');
* $httpCache->isOlderThan(15, 'minutes');
* $httpCache->isOlderThan(1, 'second');
* $httpCache->isOlderThan(15);
* If you specify something greater than "weeks" as time untit, it just
* works approximatly, because a month is taken to consist of 4.3 weeks.
* @return bool Returns true if requested page is older than specified.
* @param int $time The amount of time.
* @param string $unit The unit of the time amount - (year[s], month[s],
* week[s], day[s], hour[s], minute[s], second[s]).
if (!isset ($cacheStart)) {
* @return bool Whether the page/resource is considered to be cached.
* @param int $lastModified Unix timestamp of last modification.
if (!isset ($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
* @param int $lastModified The unix timestamp of last modification.
$this->setHeader('Last-Modified', $lastModified);
Documentation generated on Mon, 11 Mar 2019 13:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|