2010-03-25, 07:05:42
(This post was last modified: 2010-03-25, 07:09:12 by luisvaloyes.)
Would it make sense to make GT cachable?
For pages that use many xml requests, api's etc. this might make sense....
Maybe in the lines of: (just wrote code here...not tested)...
<?php
// check if cache file exists
if (file_exists('data/cache/'.$file.'.cache')) {
// check how old cache file is...and use it or rewrite it
if(date("d-m-y", filemtime('data/cache/'.$file.'.cache)) > datetime(+24hrs)){
// Read cache file
readfile('data/cache/'.$file.'.cache');
exit();
}
}
// Start buffering the output
ob_start();
// Display some HTML
?>
--- HTML CONTENT ---
<?php
$buffer = ob_get_contents();
ob_end_flush();
$fp = fopen('data/cache/'.$file.'.cache', 'w');
fwrite($fp, $buffer);
fclose($fp);
?>
one could think of adding memcache in the loop as well...
For pages that use many xml requests, api's etc. this might make sense....
Maybe in the lines of: (just wrote code here...not tested)...
<?php
// check if cache file exists
if (file_exists('data/cache/'.$file.'.cache')) {
// check how old cache file is...and use it or rewrite it
if(date("d-m-y", filemtime('data/cache/'.$file.'.cache)) > datetime(+24hrs)){
// Read cache file
readfile('data/cache/'.$file.'.cache');
exit();
}
}
// Start buffering the output
ob_start();
// Display some HTML
?>
--- HTML CONTENT ---
<?php
$buffer = ob_get_contents();
ob_end_flush();
$fp = fopen('data/cache/'.$file.'.cache', 'w');
fwrite($fp, $buffer);
fclose($fp);
?>
one could think of adding memcache in the loop as well...