Object Cache Pro
Till Krüss

Batch prefetching

The release of Object Cache Pro v1.11.0 introduces the long-awaited ability to prefetch cache keys, reducing the total amount of commands sent to Redis by up to 80%.

Let’s dig into what prefetching is and how it works.

First of all, cache prefetching is not to be confused with cache preloading, which is what most page caches use. Because a crawler/script must request and create a cached version of each post, page and product on your site, preloading (or warming) your page cache always comes at the cost of excessive server load. Object Cache Pro’s prefetching works differently.

Until now, each time a plugin, theme, or WordPress core would fetch a cache key, a single command would be sent to Redis to retrieve the key’s data. This meant anywhere from 50 to 5000 commands per page load, depending on your website. Sending this many individual commands to Redis could very quickly cause high network I/O and overall load on Redis, thus increasing website load time.

With prefetching enabled, WordPress keeps a record of what cache keys are retrieved for each page, so the next time that page is loaded, those keys are prefetched in batches early on. This is done using the MGET command to retrieve multiple cache keys at once, significantly reducing page load time.

Some plugins might not be compatible with prefetching, however, cache groups can be easily excluded from being prefetched using the non_prefetchable_groups configuration option.