• Resolved stefanoeva

    (@stefanoeva)


    Hello,
    I had a problem, every 2/3 days the size of the cache reached the limit and the status was colored in red. I was therefore advised to add this code to the function.php file

    //* Automatically cache dimensions
    add_filter('autoptimize_filter_cachecheck_maxsize','change_maxsize');
    	function change_maxsize() {
    	return 1*1024*1024*1024;
    }
    
    //* Automatically clear Autoptimize cache if it goes beyond 2GB
    if (class_exists('autoptimizeCache')) {
        $myMaxSize = 950000; # You may change this value to lower like 500000 for 500MB 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.
         }
    }

    Initially, everything seemed ok, and therefore the size of the available cache had increased.

    I realize instead that it is only a graphic feedback, but in reality the dimensions are limited to 500mb. In fact Autoptimaze never rises above this threshold. Where am I wrong?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Cache size’ is closed to new replies.