<?
class CachePag{
var $cachedir; //Este va a ser el nombre del directorio donde se van a guardor los archivos
var $cachetime; // Tiempo antes de caducar
var $cacheext; // extensión del archivo de caché
var $cachepage; // URL de la página que se va a cachear
var $cachefile; // nombre del fichero que se va a crear
var $cachelast; // variable para comrpobar si el fichero ha caducado o no
/**INICIALIZAMOS EL CONSTRUCTOR**/
function CachePag(){
$this->cachedir = "cache/";
$this->cachetime = 3600;
$this->cacheext = "cache";
$this->cachepage = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$this->cachefile = $this->cachedir.md5($this->cachepage).'.'.$this->cacheext;
}
function StartCache(){
if (@file_exists($this->cachefile)) {
$this->cachelast = @filemtime($this->cachefile);
}else{
$this->cachelast = 0;
}
@clearstatcache();
if (time() - $this->cachetime <$this->cachelast) {
@readfile($this->cachefile);
exit();
}
ob_start();
}
function EndCache(){
$fp = @fopen($this->cachefile, 'w');
@fwrite($fp, ob_get_contents());
@fclose($fp);
ob_end_flush();
}
}
?>
Puedes crear una entrada que consideres debería estar dentro de caché.