Plugin Fix for Wordpress “Edit Post” Cache Bug

Lately, after upgrading all of my blogs to the latest WordPress version, I've noticed a strange behavior when editing my posts. It appears that whenever I pressed "Save," the post content would not update on the administration console. On the other hand, it would update on the main site.
For example, if I edited a post, everything from the title to the actual body of the article would not change. I would still see the original content when logged into the administration console. But if I viewed my site, everything would appear normally. The changes would only have reflected on the actual public portion of the blog! Even weirder was that when I checked my MySQL database, nowhere was any record of the original version! So where was WordPress pulling this outdated post data from?
Research
Last night, I was getting really pissed fighting this problem. So, I scoured the message boards for choice keywords related to my dilemma. The following threads were really helpful in diagnosing the problem:
- Edited post not updating in edit window after submission
- Edit shows first version of post
- Edit post weird behavior
- Edit shows first version of post
- Website not updated when database changes
- Cache in WP 2.0 beta
- V2.0.2 and cache
WordPress Caching
Apparently, this glitch has to do with the new WordPress caching system. For some strange reason, the developers of WordPress (Don't get me wrong! They're awesome!) implemented caching in the administration console. Everyone knows that this is overkill and unnecessary! Server-side caching is best employed when a wide audience is accesses a page. Usually, only one person sees the administration console, five people tops.
Plugin Fix
So, after reading the threads, I took a member's suggestion of writing a plugin. But, instead of implementing a button that I would manually have to pressed each time things are acting up (like the person suggested), I wrote a plugin that automatically clears the cache on each administration page load.
I'm providing this plugin to the public so people will not have to go through the same ordeal. Just paste this code into a uniquely named *.php file in the "plugins" directory (Example: "admin_cache.php").
-
<?php
-
/*
-
Plugin Name: Admin Cache Disabler
-
Plugin URI: http://www.hackernotcracker.com
-
Description: A glitch in some WordPress installations does no update the "Write Post" (Edit Post) page after pressing "Save." This bug is due to the caching system in WordPress. This plugin flushes the cache on each page load in the administration console. THIS PLUGIN ONLY WORKS WITH WP 2.0 AND ABOVE!
-
Author: Allan Barizo
-
Version: 1.0
-
Author URI: http://www.hackernotcracker.com
-
*/
-
add_action('admin_head', 'wp_cache_flush');
-
?>

Subscribe by RSS Feed
Stumble it!
Furl This!
Reddit!
October 29th, 2008 at 2:10 pm
I found this post since it links to mine. I used to use Word 2007 a lot for posting to my blog. But that was till I discovered LiveWriter. You may be interested in this: http://blog.gadodia.net/using-windows-livewriter-to-publish-blog-posts/
Also, I used to have a problem with it till I realized at a much later date that it also has spellcheck: http://blog.gadodia.net/windows-live-writer-spell-check/
LiveWriter is a great replacement for Word 2007. Also, if you don't like either of these, just use FireFox or Chrome to type your posts directly into WordPress because both of them provide spell check right in the browser.
Cheers and thanks for linking to my post.