WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Nav menu update clears all blog cache (6 posts)

  1. jkhongusc
    Member
    Posted 2 years ago #

    We have a WP 3.3.1 sub-domain multisite system running that hosts about 80 blogs for our university. Whenever we update a blog's nav menu, the entire (super) cache is deleted for all our blogs. This process takes a few minutes (wp-admin is non-responsive till cache cleaning is completed) and is not what we expected nor want. We have many sites and some have quite a bit of traffic. We do not want all of our caches deleted.

    We understand that if you update a nav menu for a blog then the cache for that blog, and only that blog, should probably be deleted.

    IMO, this is a bug. This is most likely the offending line:

    wp-cache-phase2.php
    add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache' );

    James

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    That's a bug, thanks for reporting it. It should clear the cache for a single blog, not all blogs. Hopefully I'll get a fix for this soon but in the meantime delete that add_action().

  3. jkhongusc
    Member
    Posted 2 years ago #

    Thanks, I have commented out that line on our production systems.

    I am guessing what you really wanted to do was either
    wp-cache.php::wp_cache_clean_cache()
    wp-cache-phase2.php::wp_cache_phase2_clean_cache()

  4. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    I've changed the clear_cache function so it accepts a blog_id and added wp_cache_clear_cache_on_menu() to call that function so only the blog's cache files are cleared. Can you test the dev version soon? It should update in the next 20 minutes.

    http://downloads.wordpress.org/plugin/wp-super-cache.zip

  5. jkhongusc
    Member
    Posted 2 years ago #

    I do not think it is working properly. This is what I did:

    1) I downloaded and installed the wp-super-cache dev version on our test WP system. I manually removed the original plugin/wp-super-cache and copied the new dev version there. I verified that the code was changed:

    add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
    
    function wp_cache_clear_cache_on_menu() {
            global $wpdb;
            wp_cache_clear_cache( $wpdb->blogid );
    }

    2) I manually copied our production cache to the WP dev system <wp base>/wp-content/cache
    3) I went into one of our sites and updated a menu. It took about 1 minute to complete.

    Observation before nav menu update -
    Before updating the menu I noticed there were 3 subdirectories in the cache:
    <wp base>/wp-content/cache/blogs
    <wp base>/wp-content/cache/meta
    <wp base>/wp-content/cache/supercache

    Both /blogs and /supercache contained dozens of subdirectories named after our blog sites. For the site (test.usc.edu) I was about to update the nav menu I verified that it had existing cache (/blogs/test.usc.edu/*html and /supercache/test.usc.edu/*html)

    Observation after nav menu update -
    /blogs was completely empty (this included all the other site's cache)
    /supercache/test.usc.edu/ was empty (but the other sites's caches were untouched)

    I am not familiar with (super cache) caching so I do not know what the difference is between /blogs and /supercache. It appears to me that a nav menu update is incorrectly clearing all the content from /blogs, but is now correctly only clearing the blog's cache in /supercache.

  6. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for the detailed reply. That's working then. I didn't go so far as to clear out the /blogs/ folder correctly as the supercache one is the one that gets 99% of the attention/traffic. I will fix it eventually but not in a rush to do so.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic