WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Option "Clear all cache files when a post or page is published" n (8 posts)

  1. dikko2000
    Member
    Posted 2 years ago #

    I wanted to clear all super cache files when I edited a page.
    I have checked this option "Clear all cache files when a post or page is published". But it didn't work.

    I have tested by both editing an existing page and adding a new page. The cache files were all there. Only the cache file related to that page was updated.

    Can you please give me a hint where I was wrong?

    In case needed, here is the debug log (partial, numbered).

    ......
    001 07:31:23 /wp-admin/post.php In WP Cache Phase 2
    002 07:31:23 /wp-admin/post.php Setting up WordPress actions
    003 07:31:23 /wp-admin/post.php Not caching wp-admin requests.
    004 07:31:25 /wp-admin/post.php Post change: deleting cache files in /var/www/virtual/[my-root-name]/home/wwwroot/wp-content/cache/supercache/[my-host-name]/
    005 07:31:25 /wp-admin/post.php wp_cache_post_id_gc post_id: 488 http://[my-host-name]/[my-post-name]/ clearing cache in .
    006 07:31:25 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /var/www/virtual/[my-root-name]/home/wwwroot/wp-content/cache/supercache/[my-host-name]//[my-post-name]/.
    007 07:31:25 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /var/www/virtual/[my-root-name]/home/wwwroot/wp-content/cache/supercache/[my-post-name]/page/.
    008 07:31:25 /wp-admin/post.php?post=488&action=edit&message=1 Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    009 07:31:25 /wp-admin/post.php?post=488&action=edit&message=1 supercache dir: /var/www/virtual/[my-root-name]/home/wwwroot/wp-content/cache/supercache/[my-post-name]/wp-admin/post.php/
    010 07:31:25 /wp-admin/post.php?post=488&action=edit&message=1 No wp-cache file exists. Must generate a new one.
    011 07:31:26 /wp-admin/post.php?post=488&action=edit&message=1 Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    012 07:31:26 /wp-admin/post.php?post=488&action=edit&message=1 In WP Cache Phase 2
    013 07:31:26 /wp-admin/post.php?post=488&action=edit&message=1 Setting up WordPress actions
    014 07:31:26 /wp-admin/post.php?post=488&action=edit&message=1 Not caching wp-admin requests.
    015 07:31:33 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    016 07:31:33 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a supercache dir: /var/www/virtual/[my-root-name]/home/wwwroot/wp-content/cache/supercache/[my-host-name]/wp-content/themes/[my-theme-name]/editor-style.css/
    017 07:31:33 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a No wp-cache file exists. Must generate a new one.
    018 07:31:34 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    019 07:31:34 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a In WP Cache Phase 2
    020 07:31:34 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Setting up WordPress actions
    021 07:31:34 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Supercache caching disabled. Only using wp-cache. Non empty GET request.
    022 07:31:34 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Created output buffer
    023 07:31:35 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a Output buffer callback
    024 07:31:35 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a 404 file not found not cached
    025 07:31:35 /wp-content/themes/[my-theme-name]/editor-style.css?ver=3393a wp_cache_shutdown_callback: collecting meta data.
    ......

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

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Try the development version off the "Other Versions" page on the plugin homepage. That may have fixed the problem.

  3. dikko2000
    Member
    Posted 2 years ago #

    Hi Donncha,

    Thanks for the advice.
    I have downloaded dev version (after deactivating and deleteing 0.9.9.9 version from my server), but sadly it still didn't work.

    See the debug log below.

    03:06:06 /wp-admin/post.php Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    03:06:06 /wp-admin/post.php In WP Cache Phase 2
    03:06:06 /wp-admin/post.php Setting up WordPress actions
    03:06:06 /wp-admin/post.php Not caching wp-admin requests.
    03:06:07 /wp-admin/post.php supercache dir: /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/about/
    03:06:07 /wp-admin/post.php wp_cache_post_id_gc post_id: 800 http://[theme_hostname]/about/ clearing cache in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/about/.
    03:06:07 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/about/page/.
    03:06:07 /wp-admin/post.php Post change: deleting cache files in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/
    03:06:07 /wp-admin/post.php wp_cache_post_id_gc post_id: 800 http://[theme_hostname]/about/ clearing cache in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/about/.
    03:06:07 /wp-admin/post.php wp_cache_post_id_gc clearing cache in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/about/page/.
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 supercache dir: /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/wp-admin/post.php/
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 No wp-cache file exists. Must generate a new one.
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 In WP Cache Phase 2
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 Setting up WordPress actions
    03:06:07 /wp-admin/post.php?post=800&action=edit&message=1 Not caching wp-admin requests.
    03:06:11 /wp-content/themes/waohc/editor-style.css?ver=3393a Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    03:06:11 /wp-content/themes/waohc/editor-style.css?ver=3393a supercache dir: /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/wp-content/themes/[theme_name]/editor-style.css/
    03:06:11 /wp-content/themes/waohc/editor-style.css?ver=3393a No wp-cache file exists. Must generate a new one.
    03:06:12 /wp-content/themes/waohc/editor-style.css?ver=3393a Cookie detected: wordpress_logged_in_fa1b0e1d76b14648af8ed6521e67c66c
    03:06:12 /wp-content/themes/waohc/editor-style.css?ver=3393a In WP Cache Phase 2
    03:06:12 /wp-content/themes/waohc/editor-style.css?ver=3393a Setting up WordPress actions
    03:06:12 /wp-content/themes/waohc/editor-style.css?ver=3393a Supercache caching disabled. Only using wp-cache. Non empty GET request.
    03:06:12 /wp-content/themes/waohc/editor-style.css?ver=3393a Created output buffer
    03:06:13 /wp-content/themes/waohc/editor-style.css?ver=3393a Output buffer callback
    03:06:13 /wp-content/themes/waohc/editor-style.css?ver=3393a 404 file not found not cached
    03:06:13 /wp-content/themes/waohc/editor-style.css?ver=3393a wp_cache_shutdown_callback: collecting meta data.

    I noticed that in line #8 it did say "03:06:07 /wp-admin/post.php Post change: deleting cache files in /var/www/virtual/[host_root]/home/wwwroot/wp-content/cache/supercache/[theme_hostname]/". The path is right. But why are those
    files still remain there?

    How should I toubleshoot further?
    Thanks.

  4. dikko2000
    Member
    Posted 2 years ago #

    Hi Donncha,

    From the log above, the end of last part of some lines seem to be the file/folder where the operation was on. Only line 8 is related to whole supercache folder, which is what I wanted to clear when page is updated. Then I digged into plugin files and found this in file "wp-cache-phase2.php" line 997:

    if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Post change: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
    prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html', true, true );
    prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.php', true, true );
    prune_super_cache( $cache_path . 'supercache/' . $siteurl . 'index.html.gz', true, true );
    do_action( 'gc_cache', 'prune', 'homepage' );

    However, the 4 lines of code following debug message seem to be doing something with only the "index" file, instead of whole cached folder.

    What exactly does this option "Clear all cache files when a post or page is published" mean? What does it mean by "all"?

    Take an example. If my site has 10 pages. After I update page #1, will all 10 cache files be deleted, or only page #1's cache file is cleared?

    I have tested this on three sites, all faling to clear all cache files.

    Thanks.

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    I think you're on to something there! You could try add a new prune_super_cache call there but exclude the "index.html" part. I'll have a look later too.

    Thanks for digging into the code!

  6. dikko2000
    Member
    Posted 2 years ago #

    Following your suggestion, I found this API from your Holy Shmoly! blog.
    "wp_cache_clear_cache()", which looks like to be what we want.
    I finally added the calling code in, my "function.php", instead of Super Cache plugin file.

    // clear super cache when inserting, updating or deleting post/page
    add_action('save_post', 'my_clear_super_cache');
    add_action('delete_post', 'my_clear_super_cache');
    function my_clear_super_cache() {
    	if ( function_exists('wp_cache_clear_cache') ) {
    		wp_cache_clear_cache();
    	}
    }

    It worked good so far when I tested by adding new, editing and deleting exisiting pages. Do you think it's a good way?

    Thanks.

  7. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    That'll do but it's not the right way of fixing the bug, you already found that :)

    Good temporary solution however!

  8. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Can you try the development version again? This is fixed now!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic