Support » Plugins » [Plugin: WP Super Cache] When are caches updated? And scheduled posts…

  • Hi,

    I am trying to use WP Super Cache on a blog I help run. First of all, just wanted to say what a great plugin it is – wouldn’t be able to cope without it.

    I just had a few questions regarding some problems I’ve been having lately, and would appreciate anyones help. I’m using the latest release of WP Supercache

    As far as I can tell, the cache for the homepage gets invalidated on every post action – even saving drafts, and autosaves? Should this happen?

    Also, when publishing a post, the homepage gets the .needs-rebuild extension added, which correctly makes sure the homepage cache gets rebuilt. But from what I can see, the categories that the post is ticked into do not get the .needs-rebuild extension added, so the category index caches dont get rebuild on a post publish. When do the category index caches get updated? For example, should publishing a story into the “uncategorized” category mean the cache for the uncategorized category index gets invalidated?

    I also use the enable cache rebuild option – which as I understand it should mean that if I publish a new post, the next person to view the blog will get the old cached version – but WP-SuperCache will create a new cache in the background, while still serving the first person the old cache. Is this a correct understanding? So the first person to visit after a update will get the old cache, but everyone after will get the new cache? Because this doesn’t seem to work for me. Even on a test install, publishing a post instantly adds the .cache-rebuild extension to the old cache, then the next person to visit gets the latest version and the cache gets updated with the latest version – the old version never gets served while the new one is created. Is something going wrong?

    Finally, I have a question to do with scheduling posts. I schedule posts a lot and have been looking into how it works. When the time for a scheduled post passes, wordpress seems to do nothing until something is viewed – which seems correct. However, as soon as someone visits the homepage after a scheduled post date has passed, WP Super Cache marks the homepage index cache as “.needs-rebuild” – I was just wondering how WP super cache even knows to do this? I should be seeing a cached version of the homepage as directed by the .htaccess file, so the wordpress engine should never even get booted up?

    All the above were using a google chrome incognito tab to make sure I didn’t have any cookies or other sessions going on.

    I’d really appreciate it if someone could try and explain the observations? WP Supercache is critical to me, and I want to try and understand it – as I dont think its a good idea to rely on something so much without knowing how it works, and wanted to look into the few problems I’m having with it.

    Many thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yeah, the homepage is updated when posts are updated. Lots of people have requested this over the years. It should possibly check the post status before clearing it I suppose.

    Unfortunately category and tags pages aren’t cleared immediately AFAIR. Just use a shorter expiry time and they’ll recycle faster. It would be great if it did clear out those cache pages but it’s not on my TODO list. Maybe use the “clear all cache when publishing” option?

    It was probably a visitor who left a comment on your blog, or the cache just naturally expired or a visitor visited another page on your blog that hadn’t been cached, just generating a php request that called wp-cron to clear the cache for the front page.

    Hi donncha,

    thanks a lot for the reply. That helps clear up a few things.

    I had been running the scheduled posts tests on a test local install with no other users accessing it, so still not sure whats happening regarding the scheduled posts, but maybe my htaccess is failing at some point and it is kicking back into the wordpress code (I noticed WP Supercache does one last final check in code in case the htaccess fails, so I wouldn’t necessarily notice any other side effects).

    There was still just one more issue that I needed to find out, and that’s whether old caches should be served to users while a new cache is being created. I thought this is what the enable cache rebuild option does? But it doesn’t seem to work that way. Should it?

    I’m trying to prevent a situation that quite often happens on my blog in busy times, where 100 or so requests will get built up in the time taken for the first cache to be rebuilt – meaning those 100 requests never get a cache as the cache was being rebuilt and therefore didn’t exist when the request was first made. So the code has to run 100 times and brings my database server to a crawl. It would help if they all got served an old cache to return their request straight away, while the new cache was being built in the background – so a cache would only ever get built once. I thought this is what that option did? Or am I wrong?

    Many thanks again for your help,

    You could use an error_log in wp-cache-phase1.php to alert you when PHP executes?

    I guess the traffic just too great, probably. The plugin does rename the cache file for anonymous users (only!) and add a .needs-rebuild extension that is renamed on the next request. In theory the first next process to see the needs-rebuild file will rename it back to the original index.html (and .gz) and generate a file while other clients are served the cache file.

    I presume traffic is just too much for your server, or there’s a problem with the .htaccess rules and they aren’t working properly. Again, an error_log will help tell if PHP is running on a page request or not.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP Super Cache] When are caches updated? And scheduled posts…’ is closed to new replies.