Skip to content

Instantly share code, notes, and snippets.

@taylorbryant
Created January 19, 2018 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylorbryant/f47989870d55c90f8f42cdbbd0bb91c6 to your computer and use it in GitHub Desktop.
Save taylorbryant/f47989870d55c90f8f42cdbbd0bb91c6 to your computer and use it in GitHub Desktop.
Clear Autoptimize & W3 Total Cache when 64 MB limit is hit
// Clear Cache (64 MB Limit)
if ( class_exists('autoptimizeCache') ) {
$myMaxSize = 48000;
$statArr = autoptimizeCache::stats();
$cacheSize = round( $statArr[1] / 1024 );
if ($cacheSize > $myMaxSize ) {
autoptimizeCache::clearall();
if ( class_exists('W3_Plugin_TotalCacheAdmin') )
{
$plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin');
$plugin_totalcacheadmin->flush_all();
}
header("Refresh:0");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment