• Resolved Oleksandr

    (@track77)


    Hello
    How to disable purge the cache using filters?

    I try to use the next code, but it doesn’t work

    add_action('save_post', 'disable_purge_cloudflare_on_draft', 5, 3);
    function disable_purge_cloudflare_on_draft( $post_ID, $post, $update ) {
    	$update_post_disable_flush = array(
    		'draft',
    		'pending',
    		'private',
    		'auto-draft',
    		'draft',
    		);
    	if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) {
    
    		$class = new SiteGround_Optimizer\Supercacher\Supercacher_Posts();
    
    		foreach ( SiteGround_Optimizer\Supercacher\Supercacher::get_instance()->purge_hooks as $hook ) {
    			remove_action( $hook, array( SiteGround_Optimizer\Supercacher\Supercacher::get_instance(), 'purge_everything' ) );
    			remove_action( $hook, array( SiteGround_Optimizer\Supercacher\Supercacher::get_instance(), 'flush_memcache' ) );
    			remove_action( $hook, array( $class, 'purge_all_post_cache' ) );
    		}
    	}
    }
    
    add_action('save_post_form-entries', 'disable_purge_cloudflare', 10, 3);
    add_action('save_post_blocks', 'disable_purge_cloudflare', 10, 3);
    function disable_purge_cloudflare( $post_ID, $post, $update ) {
    	if (class_exists('SiteGround_Optimizer\Supercacher\Supercacher')) {
    		$class = new SiteGround_Optimizer\Supercacher\Supercacher_Posts();
    
    		foreach ( SiteGround_Optimizer\Supercacher\Supercacher::get_instance()->purge_hooks as $hook ) {
    			remove_action( $hook, array( SiteGround_Optimizer\Supercacher\Supercacher::get_instance(), 'purge_everything' ) );
    			remove_action( $hook, array( SiteGround_Optimizer\Supercacher\Supercacher::get_instance(), 'flush_memcache' ) );
    			remove_action( $hook, array( $class, 'purge_all_post_cache' ) );
    		}
    	}
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @track77,

    You can disable the Automatic Cache Purge from the Supercacher Settings tab inside the plugin interface.

    This will stop the cache purging on a specific ruleset. You can also check them in the same tab, just click on the See Rules.

    Kind regards,
    Stoyan

    Thread Starter Oleksandr

    (@track77)

    Thanks.
    But I answered about how to disable purging using filters from PHP code.

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    You can’t disable purging using filters. If you want, you can completely disable the automatic cache purge from the plugin and use our public function to purge it only when you deem necessary.

    Thread Starter Oleksandr

    (@track77)

    Big!
    Thanks – this should help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable purge cache using filters’ is closed to new replies.