You could try to replace
Code:
$fp = fopen($templatefile, 'w+');
if ($fp && flock($fp, LOCK_EX))
{
fwrite($fp, '<?php '.$cache_to_save.' ?>');
flock($fp, LOCK_UN);
fclose($fp);
}
with
Code:
if (rand() < 0.1)
{
$fp = fopen($templatefile, 'w+');
if ($fp && flock($fp, LOCK_EX))
{
fwrite($fp, '<?php '.$cache_to_save.' ?>');
flock($fp, LOCK_UN);
fclose($fp);
}
}
So basically a protection that only every 10th page call tries to write out the page.