Hey All,
First time here, I like your forum very much.
I'm finishing up on a script I'm writing and I want to add some caching features (nothing too sophisticated) to speed up the performance for those who be using my script.
Right now I have 4 include files that are included on each php page. These rarely if ever change so my thought was to have these pages cached and gzipped so that the load time for these would be minimal once the initial cache file is created.
I've tried everything I can think of to get this to work and it just won't

I'm using avery simple cache class called Cache-Kit found here:
http://acme-web-design.info/php-cache-kit.htmIt looks like this:
class acmeCache{
// public functionality, acmeCache::fetch() and acmeCache::save()
// =========================
function fetch($name, $refreshSeconds = 0){
if(!$GLOBALS['cache_active']) return false;
if(!$refreshSeconds) $refreshSeconds = 60;
$cacheFile = acmeCache::cachePath($name);
if(file_exists($cacheFile) and
((time()-filemtime($cacheFile))< $refreshSeconds))
$cacheContent = file_get_contents($cacheFile);
return $cacheContent;
}
function save($name, $cacheContent){
if(!$GLOBALS['cache_active']) return;
$cacheFile = acmeCache::cachePath($name);
acmeCache::savetofile($cacheFile, $cacheContent);
}
// for internal use
// ====================
function cachePath($name){
$cacheFolder = $GLOBALS['cache_folder'];
if(!$cacheFolder) $cacheFolder = trim($_SERVER['DOCUMENT_ROOT'],'/').'/cache/';
return $cacheFolder . md5(strtolower(trim($name))) . '.cache';
}
function savetofile($filename, $data){
$dir = trim(dirname($filename),'/').'/';
acmeCache::forceDirectory($dir);
$file = fopen($filename, 'w');
fwrite($file, $data); fclose($file);
}
function forceDirectory($dir){ // force directory structure
return is_dir($dir) or (acmeCache::forceDirectory(dirname($dir)) and mkdir($dir, 0777));
}
}
You simply include the file, then set a couple globals, then you can fetch and save the cached files via:
acmeCache::fetch ("filename", 120); // Seconds to cache file
and
acmeCache::save ("filename", $content_to_cache);
This works great for normal files that are printing something to the browser, but it won't seem to work for the source of php files.
I've tried outputting the include files to the buffer and then saving them via the function, this saves a file, but it has no content.
I've also tried using
file_get_contents() which does properly grab the content of the source files, but won't render as php when included in another php file.
I'm wondering if maybe this isn't possible, or maybe I'm doing something wrong.
Any help would greatly appreciated.
Thanks a bunch.
Tai