What you need is a caching component. First you use PHP native output control to capture all the showcontent generated ... further, you store this in a separate file daily (something as simple as cache.php ). It can be as simple as a script-based cron , which starts at 03:01 in the morning, deleting the old file and creating a new one.
Script generation example (called once a day)
<?php $cache_file="cache.php"; $heredoc_sep="START_TO_END_12";//12 just a number to keep it unlikely change as you see fit (must not ever be in CONTENT below) //Capture content ob_start(); showcontent($txtonly); $content=ob_get_contents(); ob_end_clean(); //Store in file $fp=fopen($cache_file,"w");//Truncates to zero length fwrite($fp,"<?php\necho <<<$heredoc_sep\n"); fwrite($fp,$content); fwrite($fp,"$heredoc_sep;\n"); fclose($fp); ?>
Now, to use the results, simply <?php include("cache.php");?> Instead of <?php showcontent($txtonly); ?> <?php showcontent($txtonly); ?>
source share