Batcache is a WordPress page-caching plugin that stores fully rendered HTML pages in Memcached and serves them to anonymous visitors to prevent traffic spikes from overwhelming your server.
What is Batcache?
Batcache uses Memcached to store and serve rendered pages. It takes a WordPress page request, generates the HTML once, stores it in Memcached, and then serves that stored copy to subsequent anonymous visitors. It's authored primarily by Automattic contributors and is used across WordPress.com. It requires the PECL memcached extension and the Memcached Object Cache plugin. Batcache can also optionally cache redirects.
Key Features
- Memcached page cache — Stores complete rendered HTML pages in Memcached instead of the filesystem, so multiple web servers can share the same cache.
- Traffic-spike protection — Serves cached (possibly a few minutes old) pages to new visitors to reduce CPU and database load, while logged-in users and commenters always get fresh pages.
- 40x faster page generation — Development testing showed pages generated in 200ms were served from cache in 5ms.
- Optional redirect caching — Can cache redirect responses in addition to normal pages.
- GET and HEAD only — Caches only GET and HEAD requests, skipping POST and other methods (added in v1.5).
- Cache stats in HTML — Adds a comment just above the closing head tag with Batcache stats, making it easy to verify caching is working.
- CORS support — Opt-in caching for cross-origin GET requests added in v1.5.
- REQUEST_METHOD in cache keys — Prevents HEAD responses from being served to GET requests (v1.2).
Who is Batcache for?
- Multi-server WordPress installations — Any site running on more than one server needs a shared cache like Memcached because file-based caches don't sync across servers.
- High-traffic sites and live blogs — Batcache was written for WordPress.com to keep Gizmodo's live blog up during Apple events, sustaining twice the average traffic.
- Sites that can't use file-based caching — When the filesystem is not practical (e.g., ephemeral containers or load-balanced setups), Batcache provides an alternative.
What can you do with Batcache?
- Site owners: Survive viral traffic spikes by serving stale pages to new visitors, reducing database queries and CPU load.
- Developers: Run WordPress on a multi-server architecture with a shared Memcached pool for page cache.
- Performance engineers: Cut page generation time from 200ms to 5ms in testing, allowing the same server to handle up to twenty times more traffic.
How does Batcache work?
- Install Memcached on at least one server and the PECL memcached extension.
- Upload
advanced-cache.php to /wp-content/.
- Add
define('WP_CACHE', true); near the top of wp-config.php.
- Reload a page several times and view source to see Batcache stats above the closing head tag.
- Tweak options at the top of
advanced-cache.php; optionally upload batcache.php to the plugins directory.
FAQ
Should I use Batcache?
Batcache can be used anywhere Memcached is available. WP-Super-Cache is preferred for most single-server blogs, but if you have more than one web server, Batcache is a strong choice.
Why was Batcache written?
It was created to help WordPress.com handle the massive traffic spike on Gizmodo's live blog during Apple events, where live blogs were notorious for failing under load. Batcache keeps the site up by caching pages.
What does it have to do with bats?
Batcache was originally named "supercache" but was renamed before release to avoid confusion with Donncha's WP-Super-Cache plugin. The "Bat" part came from comic book heroes, not the author's city.
Pricing
Batcache is a free WordPress plugin distributed through the WordPress.org plugin repository.
Alternatives
- WP-Super-Cache, a popular file-based WordPress caching plugin that Batcache explicitly compares itself to (Batcache is slower but works in multi-server setups).
