In the post WordPress Caching Comparisons Part 2 Matt Martz compares different caching setups, among them APC object caching together with Batcache page caching. In his post this combination seems to be the best tradeoff between setup complexity and efficiency. He doesn't mention memcached so I'm unsure if it's used or not. From reading Mark Jaquith's post APC Object Cache Backend for WordPress it seems to me that his plugin works as a drop-in replacement backend to be used in place of memcached which is what the Batcache installation instructions says to use. This is also how it has worked in my experiments with these plugins. I.e. either the APC or memcached backend is used, but not together and in combination.

However, from watching Iliya Polihronov's High-performance WordPress video (and this is where I started when looking into caching) I got the impression that APC object cache can be used for opcode caching in combination with Batcache/memchached for full page caching, for even better results. (the batcache discussion is at the very end of the video) Is this possible and would there be of any benfit, or am I just confused?

In my case I'm looking for the best solution for multiple virtual single-WordPress servers (i.e. not multisite) served by a single webserver (nginx). This runs on solid state media (Raspberry Pi/SD-card) so it would be preferable to keep cache in memory. I have full access to the system and have apc, memcache and memcached extensions installed.

edit: From reading the Batcache source my understanding is that Batcache uses whatever is offered by object-cache.php, so it's either APC or memcached object cache as used exclusively by the respective backend plugins.

Also, I found Matt's definition of bytecode, object and page caching at the end of his post enlightening.

1 Answer 1


The basic rule of thumb for Memcached is: use it if you're running multiple servers or connecting to multiple databases for the same assets.

Another more harsh way to put it: If you don't know what Memcached is, you probably don't need it.

Since you have a single server(and probably single DB) you won't be able to take advantage of several Memcached features.

Memcached: Distributed memory object caching

APC: Bytecode optimization

You can use a combination of APC and Memcached, you can also use APC with Batcache without Memcached or various combinations of plugins, so it's a bit confusing.

To clarify Batcache

Batcache has the ability to support Memcached but if you do not have Memcached installed it will still use WordPress's object cache which is defined in your config.php using define('WP_CACHE', true); and thus APC will take advantage of that.

One advantage of Batcache besides supporting complex server setups via Memcached is it does not write to file , this is why services like WordPress.com use it. Imagine if they had to static cache all their sites, it would be billions of files and impossible to manage via file I/O.

Though Batcache is fairly simple, the execution can be complex, it can be configured as seen by the comments here: http://plugins.trac.wordpress.org/browser/batcache/trunk/advanced-cache.php

To clarify Memcached

Memcached is really meant for multiple servers so they can share and use memory in a intelligent way, in essence they will share a virtual pool of memory. Each node can make use of memory from other nodes (a node does not have to be a traditional web server). Memcache does not care what language you are using since it supports most of them. http://memcached.org/about

To clarify APC

APC in simple terms is single server and PHP only. It stores all the PHP(bytecode) based compiling in RAM.

For a single server

  1. APC + Mark Jaquith's Dropin + static file cache plugin (super-cache, w3-total, etc, etc) will net you very fast results. In other words APC + a static cache is much faster on a single server then just Memcached and/or a non static cache. You can of course combine them on a single server, I have never tried that, it's doubtful there will be any improvement. Using Memcached on a single server that already has APC would be like trying to tow a car by hitching the front to the back.

  2. The alternative is to use APC + Batcache instead of a static caching plugin, this will most likely give you the same results, just make sure you have plenty of ram. This is a fine solution but it requires more server monitoring (imo) than just writing static files because servers are still finicky beasts.

If after doing one of the above and your site is still having issues, then you need to move to a new level with your hardware or start thinking about more complex setups with multiple servers.

Also bear in mind this is not about just general site "speed" but about speed + concurrency.

Don't optimize for the sake of it.. you will get to a point where optimization does nothing unless there is a demand for it.


Each server setup is different and caching is directly tied into the performance of your CPU, RAM, actual code and configurations, so results will vary...there are a lot of configuration options for both APC and Memcached.

It's important to note that https://github.com/zendtech/ZendOptimizerPlus will probably eventually replace APC.

ps. Test APC out on a dev server before you go live, it often needs fiddling with the configuration or the server might blow up.

  • Thanks for you input Wyck. I've added some more info about my setup. I'll have multiple single WordPress sites on virtual servers served by a single nginx instance. That is why I'm thinking of combining apc and memcached backends for different caching (bytecode and fullpage, the exact terms and their function is still a bit cloudy to me). It's unclear to me how to set that up. From your writing and from reading elsewhere that seems to be an option, but I can't find any configuration examples of it.
    – ivvi
    Jun 30, 2013 at 18:37
  • As per the post, there is no benefit to use memcache on a single server in lieu of APC + a caching plugin (static or memory). In other words don't bother with memcached unless you need it, and if you needed it you would know what it's for.
    – Wyck
    Jun 30, 2013 at 18:41
  • The ZendOptimizer is already part of PHP 5.5. I have just enabled it on my sites.
    – fuxia
    Jul 1, 2013 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.