batearedfox Posted May 10, 2010 Share Posted May 10, 2010 Hi I'd like to cache a few pages when a link is clicked from a backend admin page. They only need to be updated when the admin changes something and decides to update these pages. I'm using <?php // start the output buffer ob_start(); ?> //Your usual PHP script and HTML here ... <?php $cachefile = "cache/home.html"; // open the cache file "cache/home.html" for writing $fp = fopen($cachefile, 'w'); // save the contents of output buffer to the file fwrite($fp, ob_get_contents()); // close the file fclose($fp); // Send the output to the browser ob_end_flush(); ?> Which is fine for one page but I can't add another page to this script. Is there a good way to adapt this to run for 5 or 6 pages? Thanks for any help. Tom Link to comment https://forums.phpfreaks.com/topic/201235-cacheing-pages/ Share on other sites More sharing options...
andrewgauger Posted May 10, 2010 Share Posted May 10, 2010 Treat the $cachefile as a variable. do something like $cachefile="cache".$_SERVER['php-self']; Link to comment https://forums.phpfreaks.com/topic/201235-cacheing-pages/#findComment-1056113 Share on other sites More sharing options...
batearedfox Posted May 11, 2010 Author Share Posted May 11, 2010 cool, thanks. I'll have a play Link to comment https://forums.phpfreaks.com/topic/201235-cacheing-pages/#findComment-1056297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.