All of you who use WordPress together with Autoptimize Plugin they will know the problem: The additional does not automatically delete Cached files, and must be done manually.
Especially if you have the "Aggregate inline JS" and "Aggregate inline CSS" functions enabled, the amount of data collected in the cache files storage folder is huge.
So the Admin he is forced to delete the specifics by hand archives.
Below we will see some lines code which if added to the functions.php of the theme you are using will do all the work for you.
We quote the code we use in SecNews, through WPress.gr. It is configured to delete the cached files when the 512MB volume reaches.
// * Clear autoptimize cache at 512MB iGuRu.gr if (class_exists ('autoptimizeCache')) {$ iguruMaxSize = 512000; $ statArr = autoptimizeCache :: stats (); $ cacheSize = round ($ statArr [1] / 1024); if ($ cacheSize> $ iguruMaxSize) {autoptimizeCache :: clearall (); header ("Refresh: 0"); }
Of course you can change the value in $ iguruMaxSize to 1024MB if you do not want to burden your sites with ongoing php queries.
If you want to change the size, convert 1024MB to KB aka: 1024000.
That's it! Next time you will not have to delete by hand the cahced files. At the end of the code as you can see there is a refresh in the header.