NogDog wrote:How about:
cache.php:
<?php
$cache = 'cache.html';
if(file_exists($cache))
{
readfile($cache);
exit; // terminate the script here since we're outputting the cache
}
?>
index.php:
<?php
include "cache.php";
// ...rest of page...
?>
I totally understand your solution,but...
pls look my codes bellows:
mycache.php
<?php
define('THEME_CACHE_DIR',$_SERVER["DOCUMENT_ROOT"]."/cosbeta/ThemeCache"); //this is the cache-lite path
define('PEAR_DIR',$_SERVER["DOCUMENT_ROOT"].'/lib/PEAR'); //this is the pear path
$no_cache = array("/","");
$lifeTime = 3600 ;//cache life time
/*
you don't need to edit bellows
*/
ini_set('include_path', PEAR_DIR . PATH_SEPARATOR . ini_get('include_path'));
require_once "Cache/Lite/Output.php";
$options = array(
'cacheDir' => THEME_CACHE_DIR.'/cache/',
'lifeTime' => $lifeTime,
'pearErrorMode' => CACHE_LITE_ERROR_DIE
);
$cache = new Cache_Lite_Output($options);
if( $s != "" ){
$isCache = false;
}
$id_of_the_page = md5($_SERVER['REQUEST_URI']) ;
$cache = new Cache_Lite_Output($options);
/*
put bellows on the top of the page which should cache
if (!($cache->start($id_of_the_page))) {
*/
?>
the file I want to cache now like this ,it works
index.php
<?php
require_once (TEMPLATEPATH . "/mycache.php");
if (!($cache->start($id_of_the_page))) {
?>
html goes here
<?php
if( array_search( $_SERVER['REQUEST_URI'], $no_cache ) ){
$cache->save($data);
}
$cache->end();
}
else {
$data = $cache->get($id_of_the_page);
}
?>
what I want to do is just create a page like this
index.php
<?php include "cache_header.php";?>
normal html or php scripts here
<?php include "cache_footer.php";?>