PHP Classes

File: test1.php

Recommend this page to a friend!
  Classes of Cesar D. Rodas   gCache   test1.php   Download  
File: test1.php
Role: Example script
Content type: text/plain
Description: Test File
Class: gCache
Capture and cache Web page content
Author: By
Last change: Version 3.0.
+ Complete rewrite from the scratch, to improved the reponse time
+ Saves two cache, the compressed and uncompressed one. Useful for keep bandwidth.

ToDo for 3.1:
+ Add again support for file locking with not flock.
+ Add a way to mark some files in the cache to re-build ASAP.
+ Add "foldering" feature, which will spread the cache accross a set of sub directories.
Date: 15 years ago
Size: 1,195 bytes
 

Contents

Class file image Download
<?php
include("gCache.php");
$cache = new gCache;
$cache->folder = "./cache/";
$cache->contentId="var45";
$cache->timeout = 1;
/* its mean gCache cached the whole page */
/* so, gcache, decide if he must response the compressed or */
/* uncompressed cache*/
$cache->isPage = true;
if (
$cache->Valid()) {
    echo
$cache->content;
} else {
$cache->capture();
?>
<html>
<head>
<title>Cached page</title>
<head>
<body bgcolor="#CCCCCC">
    <h1>Testing Cesar D. Rodas' gCache Class</h1>
    <hr>
    <h2>Example of how to cache a hole page</h2>
    <hr>
<p>Basicaly what the gCache do, is to store a web-page or a portion of it into
  a<em> <em>cache file</em>. </em>The <em><em>cache file</em></em> has a $timeout
  in second of cache vitality, after that the cache will be re-created.</p>
<p>Also this class provides and locking system which is not depending of POSIX
  or other OS, this feature becomes to this class very portable.</p>
<hr>
<font size="1">This cache page was generated at
<?php echo date("Y/m/d H:i:s")?>
</font><font size="1"> by <a href="http://cesars.users.phpclasses.org/gcache">gCache</a>
</font>
</body>
</html>
<?
$cache
->endcapture();
}
?>