Support » Plugin: W3 Total Cache » [Plugin: W3 Total Cache] w3tc_pgcache_flush function isn't flushing cache

  • Manually clearing the page cache works fine, but I can’t get it to work by manually calling the w3tc_pgcache_flush function. I’m calling the function from the settings page of a plugin. Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frederick Townes

    (@fredericktownes)

    Can you paste the code you’re using?

    The function below is inside a class and is called by the class constructor. I get a valid return code but the page cache isn’t empty as far as I can tell.

    function tw_flush_cache(){
    		if ($_POST['tw_flush_cache']=='1'){
    			if (function_exists('w3tc_pgcache_flush')) {
    				w3tc_pgcache_flush();
    				return 'w3';
    			} else if (function_exists('wp_cache_clear_cache')) {
    				wp_cache_clear_cache();
    				return 'sc';
    			}
    		}
    		return false;
    	}
    Plugin Author Frederick Townes

    (@fredericktownes)

    When/where is that called? It’s important to make W3TC is initialized.

    The following is a rudimentary representation of where the function lives:
    (..in the main php file of a WordPress plugin…)

    class WpPluginClass{
    	function WpPluginClass(){
    		$this->tw_flush_cache();
    	}
    	function tw_flush_cache(){
    		if ($_POST['tw_flush_cache']=='1'){
    			if (function_exists('w3tc_pgcache_flush')) {
    				w3tc_pgcache_flush();
    				return 'w3';
    			} else if (function_exists('wp_cache_clear_cache')) {
    				wp_cache_clear_cache();
    				return 'sc';
    			}
    		}
    		return false;
    	}
    }
    
    $nInst = new WpPluginClass();

    The cache should be cleared when the configuration page of the plugin is saved and thus $_POST[‘tw_flush_cache’] is 1. The function returns ‘w3’ but the cache does not seem to be cleared.

    So, how do I check W3TC’s initialization status?

    Plugin Author Frederick Townes

    (@fredericktownes)

    I take it that logic working for WP Super Cache?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: W3 Total Cache] w3tc_pgcache_flush function isn't flushing cache’ is closed to new replies.