I don't know anything about fasttemplates, but I was working on a caching tool earlier today.
- Rename whatever.php to oldwhatever.php
- Make a "cache" subdirectory that is writable by the web server.
- Install the following code as whatever.php
<?
// make a filename out of the args
$fname="cache/$argv[0]";
if (!file_exists($fname))
{
$dir = dirname($PHP_SELF);
$me = basename($PHP_SELF);
// get the file and cache it
$ba=file("http://$HTTP_HOST$dir/old$me?$argv[0]");
$buf=implode("",$ba);
$fp=fopen($fname,"w");
fputs($fp,$buf);
fclose($fp);
}
readfile($fname);
?>
This code compensates for the lack of freopen() in php by routing the request through the Web server. This lets us pull the results of a page into a variable rather than echoing them to stdout.
This code would be easy to modify to support a 30-minute timeout, or you could easily write a cache-flushing tool and run it as a cron process.
The cache directory name probably ought to be specific to the instance of this code.