<?php
$cachefile = "cache/".$title.".html";
if (file_exists($cachefile))
{ include ($cachefile);
exit();
}
ob_start();
?>
Page with html and database here
<?php
$buffer = ob_get_contents();
$fp = fopen($cachefile, 'w');
fwrite($fp, $buffer);
fclose($fp);
?>
This script checks if the cached page exists and shows it instad of executing the rest of the page.
But if the page does not exist, then it opens a buffer and saves all the output into a page. It writes the page into the server so the next time it is called.
How can I do that in Perl. I have a script that consumes a lot of resources. If possible, I would like to place it before it calls the script, but that would involve passing variables through one script to another.
Is there an easy way to do so?
Thanks in advance
Enrique