Purging Fast CGI after Purging Autoptimize

Hi guys :slight_smile:

I use a code in my functions, which clear automatically autoptimize cache after reaching to 1 Gb. But it is vital to also purge nginx after this. Otherwise users see my website broken.

Right now I’m using this code, but seems nginx not purge. Do you have any solution?

# Automatically clear autoptimizeCache if it goes beyond 1 Gb
if (class_exists('autoptimizeCache')) {
    $myMaxSize = 1024000; # 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();
#       rtCamp\WP\Nginx::true_purge_all();
	add_action('rt_nginx_helper_purge_all', array(&$this, 'true_purge_all'));
       header("Refresh:0"); # Refresh the page so that autoptimize can create new cache files to prevent breaking the page after clearall.
    }
}

add_action('rt_nginx_helper_purge_all', 'true_purge_all');

Thanks