Mark Jaquith Releases Cache Buddy: A Plugin to Enhance Popular WordPress Caching Solutions

photo credit: SergioMonsalve – cc

Mark Jaquith, one of the lead developers of WordPress, released Cache Buddy on WordPress.org over the weekend. His new plugin works alongside caching solutions, such as WP Super Cache, Batcache, and W3 Total Cache, to enable WordPress to better serve cached pages to logged-in users.

Jaquith knows just about everything there is to know about site optimization and caching techniques in WordPress. He recently gave a presentation at WordCamp London 2015, entitled “Cache Money Business” where he debuted the new plugin.

He introduced Cache Buddy as “a companion for your WordPress page caching solution.” Ordinarily, when WordPress is serving pages to logged-in users or those with comment cookies, it cannot cache pages, even with popular caching plugins in place. Cache Buddy steps in to fill in the gap, allowing WordPress to serve a cached page to logged-in users by performing the following:

Changes what paths logged-in cookies are set for (so they work in the WordPress backend, but don’t exist on the front of the site).

Sets custom cookies with relevant information about the logged-in user, on the front of the site, making these cookies JavaScript-readable.

Sets custom cookies for commenters (again, JavaScript-readable), and doesn’t set the normal WordPress comment cookies.

Uses the information from these JavaScript cookies, plus some comment form magic, to recreate the comment form experience users would get from a dynamic page.

By cutting down on the number of dynamic views (cache misses), the load on your sever is dramatically decreased. The toolbar will be hidden from Subscriber and Contributor users, but Authors, Editors, and Administrators will still see the toolbar and get dynamic views.

Cache Buddy is ideal for sites that already have a caching solution in place and get lots of traffic but have no strict requirements on providing dynamic views. Jaquith summarized the kinds of sites for which Cache Buddy will not be useful:

If you have a BuddyPress site or an e-commerce site, you may honestly need WordPress logged-in cookies available on the front of your site. But if you’re just running a blog/CMS site with a significant number of commenters and logged-in Subscribers, this plugin could massively speed up your site, because requests that had to always be dynamic before, can now be served from a page cache.

Cache Buddy is available to download for free from WordPress.org. To learn more about how it works, check out Jaquith’s post introducing the plugin, as well as his slides from WordCamp London 2015.