XCache and eAccelerator Plugins for WordPress

In this episode of “The Never-Ending Quest for Better Server Performance,” we follow our heroes’ journey through the dangerous and murky woods of PHP opcode caching engines, where they aren’t content with just installing an opcode caching engine, but <gasp> becoming one with it too!

Yep, you heard that right. We’ve just released two new plugins for the WordPress users out there, that take opcode caching to the next level. If you haven’t already installed an opcode caching engine like XCache (our favorite!), eAccelerator, Turck MMcache, Memcached, APC, or PHPA then you really need to do that right now before even continuing this article. Really, what were you waiting for!?

Now that you’ve discovered the joy of opcode caching and the benefits it brings to your servers, here comes the next step: integrating the actual code your server runs with your opcode caching engine. By default, when you install the opcode cacher, it’ll sit in the background (in the memory!!!!) and memorize what each compiled PHP script looks like. Sure, it’s a lot of work, but it can be doing even more – like memorizing objects and variables in its uber-fast memory too.

The problem is that this isn’t something “easy” that happens by itself, it requires a conscious and painful effort on behalf of script developers to add an integration layer in their script that lets it communicate with the opcode caching engine. Well, that’s what we’ve done for all you WordPress lovers out there: we’ve added support for the two very popular open-source opcode caching engines – XCache and eAccelerator. Both are very good opcode cachers in their own right, but with our WordPress extensions, they become Godsends.

Installation is a snap: just extract the single PHP file for your engine, and stick it in your /wp-content/ folder to discover the truly powerful side of opcode caching! You can use these on dedicated and shared hosts, just figure out what caching engine is in use and download the appropriate file.

Download XCache for WordPress

Download eAccelerator for WordPress

< ?php include("http://neosmart.net/includes/chipin.php?type=wide"); ?>

39 thoughts on “XCache and eAccelerator Plugins for WordPress

  1. Thanks a lot for this :) … tested on localhost and live blog, and it works great (which is the same like WordPress built-in object cache with the exception this time the cache is not located at the default location)

  2. That’s good news!

    Did you use eAccelerator or XCache? Apache or IIS? Windows or Linux?

    It’s actually the same thing as the in-built object cache, except it stores the stuff in the memory instead – hundreds of times faster! We’re using it here with XCache now, it seems to be working just fine :)

  3. Ahh forgot to tell you that, i ran Linux with XCache (dont mind the header lol), and yes i do notice that it works like Object Cache, because if a page has not been visited before it’ll show high query usage but when the same page gets visited again it’ll show you less query usage (my homepage shows more than 95+ queries at first start before it gets cached, and then goes to 17 queries, and for now it just using 14 queries) .. that means it works !!!

    btw .. it’d be great if you could create some special page for this plugins to make sure that everyone get the latest update :P

  4. Thanks for sharing that info (XCache rocks! :)). Not sure I understand what you mean by “special page” though… Do you mean a page in the WP-Admin Dashboard or here on the site?

  5. Bookmarked !

    We?re still working on our software archive center which will feature a searchable archive of all our previous works and link to their appropriate pages (each is dl.php?id=somenumber).

    I guess that’s okay because i can always use google.com/search?q=site:neosmart.net/dl to search for your complete archive

    p.s modified because the previous comment marked as spam by SK although akismet says it was ham lol

  6. Thanks for this!  Decided to give it a try as I just installed eAccelerator the other night.  I’m seeing an error with the eAccelerator object-cache.php

    Fatal error: Call to undefined function eaccelerator_get() in /wp-content/object-cache.php on line 135.

    Line 135 is

    $value = eaccelerator_get($key);
  7. Dave, can you post or email me a link to a phpinfo() page on your site? (ComputerGuru@NeoSmart.net)

    I’m using XCache on NeoSmart.net and eAccelerator on my local (testbed) server with the respective plugins and haven’t come across that problem…

    I tested it with PHP 5.1.6 on Windows Server 2003 with eAccelerator 0.9.5 final…. I know neither are the latest, but I don’t recall any API changes in the eAccelerator API – especially not in a 0.0.0.2 version bump to 0.9.5.2….

  8. Hey, thanks! It works great here, no complaints whatsoever.

    eAccelerator 0.9.5.2/Ubuntu 7.04/PHP 5.2/MySQL 6

    Seeing a good improvement on this heavy-hit machine.

  9. I’ve been using APC on my server and quite disappointed with it. Sure, it is faster than nothing, but I’ve been looking at the benchmarks for some of the others (particularly XCache) and am damn impressed.

    I was using the APC thingy for WP by Mark Jaquith, but I think I’m going to take this opportunity to switch to XCache and use your plugin – hope it works! :D

  10. See I’m a newbie user of wordpress.

    I’m already using wp-cache with gzip hack enabled in it.

    I’m hosted on free web server @ 110mb.com

    Still can I install it with wp-cache already enabled

    I know this is a stupid question nut still i insist to be safe

    Which is the best one Xcache or eAccelerater ? How to decide

    Can I use eAccelerator with Wp-Cache ? Plz Help

  11. See I’ve not installed either eAccelerator nor Xcache on my server ( and I even don’t know how to do this) but only have wordpress script installed with wp-cache plugin enabled.

    Still is there any way to get speed improvements, if i enable your Xcache plugin ( without Xcache being installed on my server) in my plugins section.

    I mean can i enable both xcache  your plugin) and wp-cache on my wordpress blog?

    Further would this be safe ?

    Thanks for advice :)

  12. Gaurav, no, it doesn’t work that way. You need to have these already installed on the server. You can’t install them, the sysadmin has to. And the plugin doesn’t work without it.

  13. I get an error when I install the eaccelerator plugin. 

    Parse error: syntax error, unexpected T_IF in /path/to/wp-content/object-cache.php on line 29

     

    (This is in wpmu)

     Any ideas? thanks.
     

  14. Thanks. I tried it out, and I get the same error:

     

    Parse error: syntax error, unexpected T_STRING in /path/to/wp-content/object-cache.php on line 151

     

  15. I’m not sure what to tell you… PHP is saying that there is a problem with the code, but there is absoloutely nothing wrong with it as far as I can see… The line it’s coughing on:
    [sourcecode language='php']$eaccelerator_info = eaccelerator_info();[/sourcecode]
    I suggest double-checking the extracted/copied code and make sure nothing is getting corrupted on upload to the server…

  16. Thanks. Removing this code solves the problem, but I’m not sure what else it does. :)

    [sourcecode language='php']
    function stats()
    {
    // Note that this is the total eAccelerator stats, not just WP but also any other apps using eAccelerator var storage
    // $eaccelerator_info = eaccelerator_info();
    // echo “\n”;
    // echo “Cached Variables: {$eaccelerator_info['cachedKeys']}\n”;
    // echo “Cached Scripts:   {$eaccelerator_info['cachedScripts']}\n”;
    // echo “\n”;

    if ( !empty($this->cache) )
    {
    echo “\n\r”;
    print_r($this->cache);
    echo “\n\r”;
    }
    }
    [/sourcecode]

  17. I found a problem. With this plugin enabled in wpmu, the “Site Admin” functions are disabled. That is, the Site Admin option does not show up in wp-admin. Renaming object-cache.php to something else (not ending in php) restores the Site Admin function, and presumably disables your plugin.

  18. Klark, the only thing that I can think of is that your eAccelerator install has some restrictions (password maybe?) on eaccelerator_info() that end up crashing the script. The WP Site Admin feature is making a call to the stats() function, and since you don’t have it, it’s crashing.

    Double-check/re-compile/re-install your eAccelerator maybe? Don’t know what else to offer.

  19. ok, I just notived I forgot to mention I am on a debian server running eaccelerator. this info is all I get from the eaccelerator control panel and it does not say anything about variable cache:

     

    eAccelerator 0.9.5.1 control panel

    Information

    Caching enabled
    yes

    Optimizer enabled
    yes

    Memory usage
    99.94% (31.98MB/ 32.00MB)

    Free memory
    0.02MB

    Cached scripts
    688

    Removed scripts
    0

    Cached keys
    0

    although the number of queries did not drop. 

  20. hello, I might sound a little stupid, but google did not help me find out how to compile eaccelerator with variable cache enabled and neither does their help page: http://eaccelerator.net/wiki/CompileConfiguration&nbsp;

    I am using eaccelerator 0.9.5.1 – no need to upgrade to 0,9,5,2 as I do not use php5 yet.

    could you give me a little hint if you personally know how to do this? 

  21. hello, its me again.

    anymore ideas about this variable cache? I can’t find anything on eaccelerator and variable cache? 

  22. Looks like variable caching is not enabled in your eAccelerator setup.

    You’ll have to recompile the eAccelerator binaries with var cache support.

  23. very funny Kamper, did you read my comments? I was saying I can’t find any material on how to compile eaccelerator with variable cache enabled, neither on their site, nor with google, so if yo uhave any info for me please let me know.

  24. I have compiled xcache with those options
    ./configure –enable-xcache –enable-xcache-optimizer –enable-xcache-disassembler –enable-xcache-assembler

    set xcache.var_size = 16M, but from xcache admin page, there is no cache for variables. Did I do anything wrong?

  25. I don’t even knoww how I ended up here, but I thought this post was good.
    I don’t know who you aree but certainly you are going to a famous blogger if you aren’t
    already ;) Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>