If users update the information in their profiles, that information won't appear on the site until WP Cache gets cleared.
WP Super Cache is one of those magical plugins that does all the work for us without our having to think. We like plugins like this. We all know WordPress is a fat, resource intensive hogbeast because it has to make so many queries to the database, so when we’re hit with a spike in traffic (see: “The Digg Effect“), chances are that the whole thing might implode.
How do we get around this? Well, WP Super Cache creates static html files of our posts so that repeat visitors in a short time span don’t force WordPress to engage the database in order to serve posts and pages. Donncha O Caoimh, the creator, describes the plugin’s functionality best:
99% of your visitors will be served static html files. Those users who don’t see the static files will still benefit because they will see regular WP-Cache cached files and your server won’t be as busy as before. This plugin will help your server cope with a front page appearance on digg.com or other social networking site.
This is all fine and good, and works beautifully.* One small problem with WP Super Cache, however, is that if users update the information in their profiles, that information won’t appear on the site until WP Cache gets cleared. Also, the second time you Preview a saved draft, you’ll be seeing your last saved draft because it got cached.
So the caching drafts is a problem, but why should we care about the cached profile? Well, I ran into this problem on Rokkyuu Magazine, because users can change the color scheme of the site by setting an option in their profile. So even though they may have updated their profile, when they returned to the site, they were seeing a cached version (and their previously chosen color scheme). Moreover, at Rokkyuu, what users enter in their profile while logged in to the Dashboard appears in a members directory on the public site, which also gets cached.
To get around this, and with a bit of Donncha’s help, I added the following to functions.php:
/********* WP-CACHE: CLEAR CACHE ON UPDATE PROFILE ***/
What this does is hook the wp_cache_no_postid(0); function, which clears WP Cache, to the function that gets called when a user updates her profile.
As for the Drafts…
To fix the drafts, we do a similar thing. I couldn’t figure out how to hook into the functions that get called when you click “Preview” post or “Save Draft,” but I did find a hook that does the job.
/********* WP-CACHE: CLEAR CACHE FOR DRAFTS ***/
Adding this to functions.php clears the cache whenever I click Preview post, thereby enabling me to see my latest edits with WP Super Cache enabled.
* Plugins that display up-to-the-minute information using PHP like WP-UserOnline, for example, won’t necessarily “not work” as Donncha notes on the plugin page: they’ll just be displaying information that’s 3600 seconds old.