← All posts

Docket Cache, Redis Or Memcached?

By · · 4 min read

If you have looked into speeding up WordPress, you have probably come across Redis and Memcached. Docket Cache does the same job. All three are persistent object caches that let WordPress reuse previously cached data instead of querying the database again.

New to object caching? Start with Object Caching In Simple Terms.

WordPress can use only one of them at a time because it loads a single wp-content/object-cache.php file. So, which one is right for your site?

We make Docket Cache, but we believe in being honest. It is not the best choice for every site. This post compares the three and shows when each one makes sense.

How each one stores the cache#

Redis is a separate program that keeps data in memory. Your site talks to it over a network connection or a local socket. It is very fast, it can be shared by several web servers, and it can save its data to disk if that is turned on.

Memcached is also a separate program that keeps data in memory. It is simpler than Redis. It keeps data in memory only, so everything is lost when it restarts.

Docket Cache does not need a separate program. It saves each cached item as a small PHP file on disk. PHP's OPcache then keeps those files in memory, so most reads come straight from memory. See How Docket Cache stores and reads data for the details.

Side by side#

Docket Cache Redis Memcached
Where the cache lives PHP files on disk, kept in memory by OPcache In the memory of the Redis server In the memory of the Memcached server
Extra program on the server None Redis Memcached
PHP needs Nothing extra, OPcache is recommended A PHP extension such as PhpRedis, or the Predis library The Memcached PHP extension
Works on shared hosting Yes Only if the host provides it Only if the host provides it
Several web servers Not recommended Yes Yes
After a restart The files stay on disk Kept only if saving to disk is turned on Lost
Largest item 3MB by default, up to 10MB 512MB 1MB by default
What runs out first Disk activity and number of files Memory Memory

When Docket Cache is the better choice#

When Redis or Memcached is the better choice#

How to choose#

First, if you run more than one web server, use Redis or Memcached, so every server shares one cache. If not, and your host does not offer Redis or Memcached, use Docket Cache, which needs nothing extra on the server. If your host does offer them and you run a busy WooCommerce store or have heavy traffic, use Redis for the best speed under load. Otherwise either works. Redis is faster, and Docket Cache is simpler.
Choosing a persistent object cache

Switching between them#

Turn off the object cache in the old plugin first, so it removes its own object-cache.php file. Then turn on the new one. Some plugins add their own object cache too. For example, LiteSpeed Cache has an Object Cache option that you need to turn off before you use Docket Cache.

You do not need to move any data. A new object cache starts empty and fills itself as your site is used.

Whichever one you choose, a persistent object cache makes WordPress faster than no object cache at all. If your host does not give you Redis, Docket Cache is there for you, and it is free.