• Resolved G

    (@gnetworkau)


    Hi Donncha and all, I’ve been using Supercache for years now as it seems the best available cache plugin for WordPress. I did at sometime use mod_cache and have gone back to it for now, but it has its own problems. I would prefer to keep using Supercache – its closely integrated to both WP and Apache – but it has a long standing problem which finally got to me, hence today’s post.

    The Problem: Nuclear Cache Purge (I call it), where it purges the entire cache on Multisite, when not warranted.
    I use the plugin Tablepress, and whenever I update a table, the entire cache gets purged. At all other times everything works perfectly, if I update a page/post only that page is refreshed, so all good.
    I think Tablepress may post as a custom post type, but I read in the supercache development posts that custom post type issues had been resolved…?

    My settings include:
    Expert Mode (yes all htaccess rules used are good)
    Refresh pages only when comment is made

    I would like to see an option of No Purge at all, unless by page hard reload.

    Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter G

    (@gnetworkau)

    I have just come back to using Supercache, as mod_cache was too problematic. Supercache works perfectly except for that one small problem. I investigate further, and still open to suggestions…

    These are all my active settings:

    EXPERT Mode
    Don’t cache pages for known users. (Recommended)
    Don’t cache pages with GET parameters. (?x=y at the end of a url)
    Compress pages so they’re served more quickly to visitors. (Recommended)
    Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated. (Recommended)
    Only refresh current page when comments made.

    Thread Starter G

    (@gnetworkau)

    I solved it myself, by disabling the offending code. This is how…

    In the file wp-cache-phase2.php comment out the 2 lines in this section:

    
    /* Clear out the cache directory. */
    ...
    //	prune_super_cache( $cache_path . 'supercache/', true );
    //	prune_super_cache( $cache_path, true );

    No more nuclear purges – sweeeet!

    It seems that you changed the code in function wp_cache_clear_cache. This function is using only from hook wp_update_nav_menu and I’ve tried to search codebase in TablePress (I’ve found method _flush_caching_plugins_caches in models/model-table.php):

    /**
     * Flush the caches of the plugins W3 Total Cache, WP Super Cache, Cachify, and Quick Cache.
     *
     * @since 1.0.0
     */
    public function _flush_caching_plugins_caches() {
    	/**
    	 * Filter whether the caches of common caching plugins shall be flushed.
    	 *
    	 * @since 1.0.0
    	 *
    	 * @param bool $flush Whether caches of caching plugins shall be flushed. Default true.
    	 */
    	if ( ! apply_filters( 'tablepress_flush_caching_plugins_caches', true ) ) {
    		return;
    	}
    
    	// W3 Total Cache
    	if ( function_exists( 'w3tc_pgcache_flush' ) ) {
    		w3tc_pgcache_flush();
    	}
    	// WP Super Cache
    	if ( function_exists( 'wp_cache_clear_cache' ) ) {
    		wp_cache_clear_cache();
    	}
    

    It’s an issue in TablePress because it isn’t good approach for multisite installation. We could create an issue on TablePress forum.

    Also, you can use filter tablepress_flush_caching_plugins_caches to prevent running of this code. I think that following code should work (and you don’t need to change code in WPSC):

    add_filter( 'tablepress_flush_caching_plugins_caches', '__return_false' );
    
    Thread Starter G

    (@gnetworkau)

    @stodorovic thanks for that – it works!

    It already was discussed in Tablepress forum.

    I would have liked to stop the purge from the Supercache side, as any rogue plugin could initiate a purge in future. I prefer that the cache is NEVER purged; if there is a major upgrade, I can press “Delete Cache on all blogs” or clear by ftp.

    I tried the following but it did not work:

    global $cache_path;
    remove_filter( 'wp_update_nav_menu', array($cache_path, 'wp_cache_clear_cache') );

    Ok for now…

    I think that remove_action should be called later and function wp_cache_clear_cache_on_menu isn’t method in any class (you don’t need to pass any instance). You can try this:

    add_action( 'init', function() {
    	remove_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
    }, 20 );
    

    I didn’t tested (but I’m pretty sure that will be called after add_action).

    Thread Starter G

    (@gnetworkau)

    I tried this, but Tablepress blew it away.
    If you know of any function that can totally disable full cache purge, I would like to know, but I don’t really need it right now, as the filter to tablepress is doing the job. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Stop Nuclear Cache Purge’ is closed to new replies.