Просмотр файла AlberT-cache/Documentation/ric_README.html

Размер файла: 5.42Kb
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <link rel="stylesheet" href="media/stylesheet.css" />
<!-- template designed by Julien Damon based on PHPEdit's generated templates, and tweaked by Greg Beaver -->
<body bgcolor="#ffffff" ><div align="center"><h1>README</h1></div>
<pre>
# $Id: README,v 1.5 2004/12/14 17:37:22 albert Exp $ #

AlberT-cache is a lightweight, full page caching system written in PHP.
It reduces server-load, as pages are generated less often.

It dramatically speeds up the serving of your pages, by caching the ouput of
pages and returning them instead of reparsing  the PHP page.

It also uses gzip content-encodig and ETag-headers, which results in around 80%
in traffic-saving for PHP pages.
This feature is NOT avaible in Win becouse gzip functions are not supported here.

Cached pages are stored files in a local dir, by default cache/ dir; AlberT-cache
does NOT use system temporary direcories for portability and security.

Features:

- Caches full php pages for &lt;X&gt; seconds
- When not modified since last visit, sends '304 Not Modified' response
- When modified or first visit, sends gzipped content if possible, else uncompressed
  content
- Takes GET, POST and user definible data into account when caching (you can cache
  also SESSION or COOKIES, or whatever you want !)

Requirements:
 - PHP 4.1.0+ (we use only Superglobals for security)

Quick usage:

- Edit config.inc.php and change the configuration settings
- Start the file you want to cache your file with
  &lt;?php $CACHE_TIMEOUT=&lt;X&gt;; include 'AlberT-cache.inc.php ?&gt;
  where in the include you have to give the path to AlberT-cache.inc.php file, if
  it is not in the current.
- Setting &lt;X&gt; to -1 will disable caching and will only do content encoding.
  This can be used for pages that are not cacheable due to user-specific
  content (polls, personalization etc.)
- These vars may be rewriten in each page to be cached:
  $CACHE_GZIP,  Whether or not to use GZIP
  $CACHE_POST,  If we should cache POST
  $CACHE_TIMEOUT, Will disable cache, gzip allowed if possible
  $CACHE_ALSO, Put here additional vars to be cached

First version was based upon and inspired by jpCache.


                       How AlberT-cache works

in every page you want the caching mechanism you can _optionally_ define same per page
variables, i.e.:

- $CACHE_GZIP:    tells if the compression of the cached page has to be used or not.
                  Defaults to 1 (gzipping active).
- $CACHE_POST:    tells if the POST data have to be used or not in the generation
                  of the cached page's identifier (say a different set of POST's
                  data raise different cached pages).
                  Defaults to 1 (active).
- $CACHE_TIMEOUT: time (in minutes) after whose the cached pages will expire.
                  Note that if not setted or setted to NULL then the $CACHE_EXP
                  unoverwriteble variable will be used to set te expiring time.
                  Defaults to NULL, set it to -1 to disable caching for this page.
- $CACHE_ALSO:    Here you can put a variety of data to be used in the same way of
                  the previous $CACHE_POST.
                  Some good choice may be: $_SESSION, session_name(), $_COOKIE['user'], etc.
                  You are free of adding these vars to $CACHE_ALSO as you want, infact it
                  will be then serialized aand used as arg of md5().

Let's now explain briefly how AlberT-cache works.

The browser asks for the page and the CACHE_start() is invoched.
CACHE_start() first invoches CACHE_init() that makes some checks over the configuration variables,
then same simple functions build the name of the container object (a file name at the moment)
untill CACHE_thecache() searches for a previous copy of the cache file and if it is not expired
flushes it to the browser.
As the cached file is gizipped (if $CACHE_GZIP is true), we send appropriated headers to the browser
that in most cases gunzip the conten on the fly; if browser says it can (it's improbable as modern
ones can) we must gunzip first.
If the broser sais (E-Tag header) that it has the page in it's cache we send only a &quot;304&quot; header,
so that we save our band width (it means the browser as a valid, not expired copy of the page !).

If no previous cache is found, than an output buffer is invoked with 'CACHE_end' as argument...
then exit.
Now the page is genearated as the cache does not exists ..
When our page has finished outputing the function CACHE_end() is invoked by php as a callback of
the ob_start, so we can regain the control.
CACHE_end() does a simple job: gzip the data from output buffer (if $CACHE_GZIP is true),
cache some data about the page, as the crc32, becouse they are about original content,  which is lost
after this stuff. And finilly saves the data ready to be used in the container that at the moment is
a file who's name is calculated on appending to the URI of the requested page a string of 32 chars
obtained from the md5() of the $_GET, $_POST (if $CACHE_POST is true) and $CACHE_ALSO.

That's all ... enjoy


</pre>
	<div id="credit">
		<hr />
		Documentation generated on Wed, 15 Dec 2004 15:11:09 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a>
	</div>
</body>
</html>