Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] Homepage not refreshing – Garbage Collection problem

  • Hello Donncha,

    we had issues with one of the sites, where the homepage was 5 days old, even though there were new posts every day. I was checking for possible plugin conflicts and so on.

    I noticed that when the plugin is installed, the Garbage Collector event wp_cache_gc is scheduled only as a “One-off event”. So I have to set the Scheduler -> Timer to 3600 seconds and hit “Change Expiration”, then I can see that it’s scheduled properly. Perhaps this stopped the homepage from refreshing?

    The wp_cache_gc is also not scheduled when upgrading the plugin from older versions (0.9.9) or switching from “Use mod_rewrite to serve cache files.” to “Use PHP to serve cache files.”. So we have to hit that “Change Expiration” button again. That means each time we tweaked some setting, the issue came back.

    What’s most confusing is, that this is not indicated on the WP Super Cache options screen, so we were not aware of any of these issues. There is visible check of the garbage collector cron job.

    Thanks,
    Martin

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

Viewing 7 replies - 16 through 22 (of 22 total)
  • Dont know why but my garbage collection is not at all working.

    It shows below message in advanced setting page.

    UTC time is 2012-08-31 17:32:51Local time is 2012-08-31 23:02:51
    Next scheduled garbage collection will be at 2012-08-31 17:32:32 UTC

    Also, I have enable email option whenever it runs but not getting any email for this.

    (I am using wp super cache for last 3 years, it works like charm but after my server upgrade last week, its not working.)

    Please help me to fix this.

    Is there any way we can set server cron job to run garbage collection?

    When I check in cron view, its displaying as below.

    Aug 31, 2012 @ 17:32 (1346434352) One-off event wp_cache_gc

    I dont know what does it means?

    Hi Donncha,

    I just wanted to say I am really happy with the latest version. So far, everything – including preload (and we have 14,000 posts so far) – has gone smoothly, and it seems various bugs have been fixed. So many thanks for a great job done.

    I would like to make a suggestion, however, perhaps for future versions.

    Add a few options for what happens when a post is published:

    When a post is published:

    – Check box to clear homepage chace
    – Check box to clear author page cache
    – Check box to clear related (and only related) taxonomy (category/tags/custom taxonomy) cache

    I already added functions to my functions.php that do this on save_post, but I reckon this is important – especially for folks like me who use preload.

    Many thanks again,

    Bira

    Plugin Author Donncha Ó Caoimh

    (@donncha)

    @biranit – any chance you could send me a patch adding that code to the plugin? It’ll also need a settings page with those checkboxes of course.

    @biranit You have just saved my life that your temporary solution suited me perfectly.

    @biranit
    I would like to clear the homepage-cache, when a new post is published.
    Can you please send me the code, that you use in your functions.php? It would be nice.

    Hi Madd1974,

    I don’t actually use a specific function for the homepage — I did try in the past to use do_action( ‘gc_cache’, ‘prune’, ‘homepage’ ); — but that did not seem to work for me.

    So instead, I have something more explicit — probably a not the shortest version possible, but it works…

    Put this function in your theme’s functions.php — it will delete the cached homepage on every published post save (that is, if you publish a post and/or update a published post). Feel free to change as needed:

    function prune_wpsc_homepage_on_post_save ($post_id) {
    
    	if ( $post_id == null || empty($_POST) )
    		return;
    
    	// remove these next two lines of code if you want the hp to
    	//  be deleted on save_post of other post types than regular posts
    	if ( !isset( $_POST['post_type'] ) || $_POST['post_type']!='post' )
    		return;
    
    	if ( !wp_is_post_revision( $post_id ) ) {
    		// explicitly removes all versions of the homepage - compressed and mobile
    		prune_super_cache( get_supercache_dir() . '/index.html', true );
    		prune_super_cache( get_supercache_dir() . '/index.html.gz', true );
    		prune_super_cache( get_supercache_dir() . '/index-mobile.html', true );
    		prune_super_cache( get_supercache_dir() . '/index-mobile.html.gz', true );
    	}
    
    }
    add_action('save_post', 'prune_wpsc_homepage_on_post_save', 15 );

    Let me know if you have any questions.

    Cheers,

    Bira

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘[Plugin: WP Super Cache] Homepage not refreshing – Garbage Collection problem’ is closed to new replies.