WordPress.org

Support

Support » Plugins and Hacks » WP Super Cache » [Plugin: WP Super Cache] Clear all cache should'nt be executed on a draft post

[Plugin: WP Super Cache] Clear all cache should'nt be executed on a draft post

  • Hello,

    I’m using WP Super Cache with this setting :

    Clear all cache files when a post or page is published or updated

    When I update a draft post, all the cache is cleared. But this plugin should’nt work this way. In order to publish a new post, I usually write during a few hours, and I may save this post a lot of time. Each time I do so, the cache is cleared (and becomes useless).

    Can it be fixed ?

    Regards,

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • You know you don’t need to have the ‘Clear all cache files when a post or page is published or updated’ option set if you only care about updating the cache for the current page/post you’re working on, right? It will clear the cache of just that page when you save it.

    I know that it’s not compulsory.

    But on my website I need to empty the cache when i publish or update a post, because there is many links between each of my post and because my cache timeout last a few days.

    The “Clear all cache files when a post or page is published or updated” shouldn’t work this way on a draft postn, beacause there is no need to empty a cash when a user is updating an invisible post…

    Confirming the bug. I tested @confridin‘s issue against dev version of plugin and this does in fact happen. I can also say it’s not happening where you would expect. I thought there would be a bug in wp_cache_post_change, but there are checks to see if the item has a status of ‘publish’ and it leaves the function if it does not. So the issue is somewhere else.

    OK I figured it out. If you want to patch your code, you can do it with this…

    in wp-cache-phase2.php, find

    function wp_cache_post_edit($post_id) {
    	global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;

    Right below the declaration of globals, add

    $post = get_post( $post_id );
    	if( $post->post_status != 'publish' ) {
    		if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
    		return $post_id;
    	}

    Note: copied code from wp_cache_post_change in same file.

    Thanks for your help jrevillini. It works !

    Can this code be included in a new version of the plugin by the author ?

    I think it would be great if he thinks the code wouldn’t introduce new bugs. Leave the thread unresolved so he reads it and maybe lets us know his plans.

    Plugin Author Donncha O Caoimh

    @donncha

    Thanks jrevillini, I just added this to the development version!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WP Super Cache] Clear all cache should'nt be executed on a draft post’ is closed to new replies.
Skip to toolbar