WP Super Cache with Object Cache support

Here’s a quick post to encourage brave testers. I’m adding object cache support to WP Super Cache so you’ll be able to store your cached files in a memcached backend instead of disk.

It’s not complete but it’s running on this blog and well, you’re reading this which means it’s doing something and not breaking! If you want to give it a go grab the development version from the download page.

There are few caveats, but three spring to mind:

It won’t cache anything for “known” users. That is users who are logged in or leave comments. Usually a tiny minority of the visitors to any site.

Refreshing of the cache is very incomplete. If you leave a comment, the cache for that page may not update immediately. The cache lifetime is set to 30 seconds, and after you leave a comment you become a “known user” and see the uncached version of the page anyway.

When posts are updated the whole cache is invalidated.

If you don’t know what memcached is, or how to set it up then you probably don’t want to test this. If you do, use Google and find out about them. Unfortunately I don’t have time to explain how to install it.

Inspiration and some code taken from batcache, the excellent caching plugin we use on WordPress.com.

Update! I updated the Changelog in the readme.txt and I’m looking for testers. Here’s what’s new in the development version:

The biggest changes are the addition of the object cache and a small change to the php code that serves cached wp-cache files. If the mod_rewrite rules on your site don’t work for whatever reason the plugin will look for the Supercache file and serve that instead. An extra header is added to the served page when this happens. It’s all in the readme.txt!

I have revision 199000 checked out (and downloaded that very ZIP file — saying tarball is a bit of a habit), and there doesn’t appear to be any memcache related code in it.

Oh. Hold the phone, there’s an idiot on the other end. Generic WordPress object cache API support… that makes total sense. Very nice.

(reads relevant code after brain rearrangement)

Thought: nginx has a memcache module which can serve pages directly out of memcache… I suspect the keys you’ve chosen might preclude doing that right now, but I’ll have a check, and suggest changes if it makes sense.

How come you don’t inform people that after installing this cache plugin there is almost no way to delete it! You should make that clear before just allowing people to just download it. So if it messes up more peoples blogs they will understand that they will have to start completely over.

there is also no video showing how to manually uninstall it, and the delete button to the plugin does’nt even work. So even if i wanted to uninstall it, and reinstall it there is no way possible. This is just not cool.

Why do you need a video? There are instructions in the readme.txt on how to uninstall it!

Yes, it’s harder to uninstall this plugin than most others, mainly because it creates files but the knowledge learned figuring this out will help you when doing other admin jobs on your server. Never stop learning.

well I just tried to open the uninstall file and windows vista can’t open it. So what do I do with this pluggin. I can’t get into the settings neither, and google is no longer indexing my blog posts because of the cache issue. isn’t there any way of removing it?

This is the instuctions I got. So where do I go in wordpress to do them, it doesn’t say:
==============================================================
Open your browser and load wp-content/plugins/wp-super-cache/uninstall.php directly. You must be logged in, and you must confirm the action. If you do not delete the plugin immediately, after the script runs, please comment out the define() above to stop someone else running it.

To manually uninstall:

1.Remove the WP_CACHE define from wp-config.php. It looks like define( ‘WP_CACHE’, true );
2.Clear the cache in the backend page and then deactivate the plugin on the plugins page.
3.Remove the Super Cache mod_rewrite rules from your .htaccess file.
4.Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
5.Remove the directory wp-content/cache/
6.Remove the directory wp-super-cache from your plugins directory.

You have to open wp-config.php in a text editor. I use ssh, you possibly use ftp or some other method. None of the 6 points above are done through WordPress. Use Google to find out how on your particular hosting provider.

Donncha, Would this plug-in be a problem with my Google Friend Connect? When I up loaded the plug…my friends disappeared. I have them at my GFC account but the people are not showing up on my blog. If this is the case how do I fix this problem? Help please
Debby
Thanks

All right, I’m trying this with a server using the latest eAccelerator (0.9.6). There is nothing visible in your plugin to indicate whether or not it’s making a difference, or whether object cache support is switched on. What am I looking for?

I think sentence one makes it clear that “I’m trying this with a server using the latest eAccelerator (0.9.6),” which means that, yes, it is installed. It is an option in cPanel, using their EasyApache feature. My PHP info shows eAccelerator is enabled. The question is how do I know your plugin is working with it?

Gene, there’s no need to be rude. Consider that it’s highly likely that Donncha has more idea what he’s talking about than you.

The key issue for you: There is a difference between “eAccelerator is installed” and having a WordPress object cache adapter for eAccelerator installed (check wp-content/object-cache.php — if that file doesn’t exist at all, then you have egg on your face, and should apologise).

Donncha mentions experimental support. Is it restricted to memcached, or will it work with eAccelerator and XCache. Is there anything in WP Super Cache that will show if it is supporting object caching?

Rude? Well, put it this way. I’m being told twice, after explaining I have something installed, to install that particular item. Isn’t it rude not to pay attention to what someone is writing about?

I’m not missing the point. In fact, if you look at my comments way, way above, I *was* fundamentally missing the point (of how Donncha’s changes worked, not your little protestations), and then realised my mistake.

The new functionality is not restricted to memcached. It will work with absolutely any system for which you provide an object caching adapter for WordPress, as Donncha’s code uses those APIs (cf. my realisation above).

If you do not have an object cache adapter for eAccelerator installed in addition to eAccelerator itself, then you won’t be seeing the impact of this new functionality.

Now, I’ll note that Donncha’s original reply was, “Youâ€™ll need an eaccelerator object cache too”. Sure, he didn’t exhaustively explain the background to that, but it was concise and correct — and he suggested you Google for it.

Do you have an object cache adapter for eAccelerator installed? Because between your rudeness, you still haven’t answered that. Again, check for wp-content/object-cache.php — but really, you’d already know if you had installed one.

OK, I put the most recent one, dated 2009, in, but when configuring WP Super Cache to recognize it, after saving the update, the site produces nothing more than blank pages. Same for the Dashboard. Solution was to remove the object cache file. Yes, it was correctly installed, in the main WP Content folder.

Since two of the four WP blogs I use have different plugin setups, I’m assuming the experiment needs a bit of work.

You use eAccelerator, I use APC and memcache, someone else uses Xcache, and I’m sure there are plenty more object cache adapter implementations… doesn’t seem sustainable or worthwhile to include them in wp-super-cache or WordPress itself.

Hi, I’ve been testing the memcached-object cache enabled version for a full week on a few busy WordPress sites with lots of plugins. I did not encounter any fatal bug (no page or server crash). However there are some serious drawbacks that forced me to disable the object cache on one of the sites:
– New comments did not appear, and older comments keeped up reappearing in the “recent comments” widget randomly.
– The integrated standalone bbPress forum that I use did not list new forum posts at all.
– Cached featured RSS feeds did not update properly.
– Sometimes the home page of the site was incompletely rendered (sidebars missing)

On another busy site (multisite enabled) where there is less user comment activity and no forum, everything works fine, with a threefold decrease in database traffic.

On yet another multisite I could not activate object cache at all (resulted in blank pages or server error), I still have to check out which plugin causes the incompatibility.

The memcached acceleration and database traffic decrease were absolutely stunning. I think that for the complete setup to be effective on community sites, a solution has to be found for automatically clearing specific cached objects when a new comment / new forum post / new rss feed is available.

@Nathaniel: If you don’t know how to access to your webserver with ssh and deal with the linux system using the terminal tool (command line), you’d better not try advanced and risky plugins like it. It’s clear this tool is not for everyone. As stated, it can bring good benefit when properly installed in heavy loaded websites (which maybe it’s not your case, so you can be worrying about this long hours for no benefit).
When you get a technical problem that is over your level of expertise it can be very stressing, as time is gold in the Internet. Technical people normally don’t use CPanel to deal with their servers, they connect directly and change the config files, or at most use Virtualmin.

The Golden Compass
First of a three part fantasy/sci-fi series. Some people hate it because of it's anti God message but it's a great read. I found it hard to put down. There's even a Snopes article about the film adaptation.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.