Code-Snippets-Functions/Execute a function on a child site/Autoptimize/purge-cache-when-over-256mb-in-size.txt

10 lines
458 B
Text

if (class_exists('autoptimizeCache')) {
$myMaxSize = 256000; # You may change this value to lower like 100000 for 100MB if you have limited server space
$statArr=autoptimizeCache::stats();
$cacheSize=round($statArr[1]/1024);
if ($cacheSize>$myMaxSize){
autoptimizeCache::clearall();
header("Refresh:0"); # Refresh the page so that autoptimize can create new cache files and it does breaks the page after clearall.
}
}