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:

* Added experimental object cache support.
* Added Chinese(Traditional) translation by Pseric.
* Added FAQ on WP-Cache vs Supercache files.
* Use Supercache file if WP-Cache file not found. Useful if mod_rewrite rules are broken or not working.
* Get mobile browser list from WP Mobile Edition if found. Warn user if .htaccess out of date.
* Make sure writer lock is unlocked after writing cache files.
* Added link to developer docs in readme.
* Added Ukranian translation by Vitaly Mylo.
* Added Upgrade Notice section to readme.
* Warn if zlib compression in PHP is enabled.
* Added compression troubleshooting answer. Props Vladimir (http://blog.sjinks.pro/)
* Added Japanese translation by Tai (http://tekapo.com/)
* Updated Italian translation.

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!

44 thoughts on “WP Super Cache with Object Cache support

  1. Quick question re the merge. Will we still need your superb domain mapping plugin to map domain names to wordpress multiple sites or will that too be part of the merge?

    Cheers,

    ~m

    1. Mike – I don’t know. The plugin is so complicated that I wouldn’t like to see it in core as it will trip up people who aren’t willing or able to understand how it works or how to set it up.

      1. Sure, I understand.

        It’s no big deal, that plugin is so useful it’s untrue! It also removes any need to sign up for the extortionate cost of services such as wp.mu.

      1. 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.

  2. 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.

  3. 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.

    1. 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.

    1. Probably, especially if you need to change file permissions I guess. I’ve never used hostgator and hardly ever used c-panel so I can’t help you there.

  4. 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?

  5. If you could just e-mail me the the uninstalling instructions that would be nice, because i can’t open the file.

  6. 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.

    1. 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.

  7. open browser and load wp-content/plugins/wp-super-cache/uninstall.php directly??? That doesn’t make sense by itself.

    1. You probably wouldn’t use it. Batcache is more mature and stable but a lot of people don’t know about it. My plugin is possibly more flexible because of all the actions and filters included in it.

    1. Possibly, but unlikely. The list of cached files would have to be stored in the database. There’s already a list of recently cached pages which can be used.

  8. 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

  9. 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?

    Peace,
    Gene

  10. 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?

    Peace,
    Gene

  11. I think there’s a communication breakdown here, so let me try again:

    1. eAccelerator is installed.

    2. eAccelerator is installed.

    Did I tell you eAccelerator is installed?

    Now I am asking, for the third time, how I determine if your plugin is working with it or not?

    Peace,
    Gene

    1. 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).

  12. Jeff, you’re missing the point too.

    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?

    Peace,
    Gene

    1. 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.

  13. 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.

    Thanks for the clarification.

    Peace,
    Gene

    1. 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.

      No apology for being a douche to Donncha? Disappointing.

  14. Happy to apologize. But Donncha owes me one too for his obtuse instructions that did not make it fully evident that one should look for one of these plugins until the question was asked.

    In any case, I found something with a 2009 date on it, and the original. If anyone manages to find one for eAccelerator that will work, great.

    I suggested a supported version, rather than have people fend for themselves, because it would then provide some degree of predictability and reliability.

    Peace,
    Gene

  15. I’ve a better question: Other than the granular configurations provided by WP Super Cache, isn’t it otherwise just serving as a front end to an object cache plugin using this method?

    Peace,
    Gene

    1. Well, it’s just using the cache to store the complete page rather than using the disk.

      The object cache is usually used to store discrete objects but can store anything.

  16. Thanks. Anyway, I am looking forward to updates that will, hopefully, work with the object cache plugin I’m testing, the latest I found that supports eAccelerator.

    Peace,
    Gene

  17. 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.

    In my setup I use the *great* CDN feature of WP Super Cache to serve statics files with Nginx. There’s a huge 300 Meg in-memory eAccelerator opcode cache, and a 64 Meg Memcached. The MySql server is on a distinct host, and uses persistent database connections. The PHP / Apache / Nginx / eAccelerator / Memcached server hosts half a dozen WordPress sites totaling 10 to 15K daily visitors in 4 GB RAM.

    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.

  18. @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.

  19. I have installed developer version and memcached wordpress support, and memcached on my server, but still can’t find where to enable memcache in plugin

Leave a Reply

%d bloggers like this:

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.

Close