Last updated on

While Page Caching can greatly help to reduce the response time of a site through caching static pages, there are still many non-cached requests for Objects. Object Caching will further improve performance by caching these Objects.

The idea of an Object Cache is that the WordPress Core, themes, and plugins may store some data that is frequently accessed and rarely changed in an object store. This is so these objects will not have to be retrieved and processed on each request. Ultimately, Object Caching will reduce the total number of database queries required for each page, and because the CPU does not have to rebuild these blocks of data your response time will decrease.

In reality, this potential performance improvements of Object Caching are highly dependent on which plugins or themes you use and whether they correctly store these objects. For example, your response time may not decrease if objects are stored and rarely (if ever) used.

Speed Up Your WordPress Website.

A Difference of Just 100ms in Page Load Speeds Can Cause a Visitor to Prefer Your Competitor’s Website.

Choosing a Method

Object Caching assists in improving performance by reducing the total number of database queries required to generate pages for many users. This works by freeing up MySQL server resources taken by serving repeated queries returning the same data each time, so that it has more power to handle real dynamic data.

For suggestions tailored to your hosting plan and recommendations on which Object Caching method to use, consider upgrading to W3 Total Cache Pro for access to the Statistics page.

Shared Server

In shared hosting platforms, you may only be able to cache files to a disk. In such cases, there is only one option available for Object Caching unless your hosting provider has a method listed under VPS / Dedicated Server or Multiple Servers available.

Disk

Disk-based caching stores the Objects to a folder within wp-content/cache as a file or set of files. Disk-based Object Caching is generally not recommended unless you are caching a small number of objects that are not likely to change often.

Caveats

Unless you have a specific scenario where you are willing to manage Global Groups and Non-persistent Groups under Object Caching > Advanced, it is best to consider upgrading to a VPS / Dedicated Server where in-memory solutions are possible, or using a third-party solution.

VPS / Dedicated Server

On VPS and/or Dedicated hosting platforms you may use an in-memory caching solution rather than exclusively caching to disk. In-memory caching takes advantage of the much faster read/write speeds and lower latency of accessing data from system memory compared to disk-based alternatives.

Alternative PHP Cache (APC / APCu)

APC refers to Alternative PHP Cache which provides in-memory Opcode caching and a key-value store for looking up cached items. This is largely deprecated in favor of modern Opcode Caching mechanisms, as APC is not supported in the PHP 7.x branch.

APCu is similar to APC, though in order to support modern variants of PHP it is stripped of Opcode Caching and only provides the in-memory key-value store mechanisms. When paired with modern Opcode Caching mechanisms it can provide the functionality originally provided by APC, though it should only be used when you require having a limited cache size.

APC/APCu is not stable when a lot of memory allocated. In cases where you are caching a small amount of data, APC/APCu may be the ideal method for single-instance hosting platforms such as VPS or Dedicated hosting.

eAccelerator

eAccelerator is an in-memory Opcode caching solution that supports the PHP 4.x and 5.x major versions. This is largely deprecated in favor of modern Opcode Caching mechanisms, as eAccelerator is not supported in the PHP 7.x branch.

XCache

XCache is an in-memory Opcode caching solution that supports up to the PHP 5.6 release. This is largely deprecated in favor of modern Opcode Caching mechanisms, as XCache is not supported in the PHP 7.x branch.

WinCache is an extension for Microsoft IIS which provides in-memory Opcode caching and currently supports up to IIS 10 as of 04/30/2019. Check the official Microsoft product page for the latest information.

Multiple Server

If you have multiple hosting plans where one plan has root-level access, or if your hosting provider offers addons or bundles providing one of the following solutions, you may offload your in-memory caching to another server. This allows you to separate your actual site and caching solution between multiple servers to compliment each other, and allows for easier scaling to serve many users.

Memcached

Memcached is a high-performance, distributed memory object caching system meant to speed up dynamic web applications by alleviating database load. It provides an in-memory key-value store for small chunks of arbitrary data (strings, objects) from the results of database calls, API calls, or page rendering.

Memcached is ideal for relatively small and static data, and as a result may be more efficient than Redis. It is also multithreaded, which may be a benefit when using a VPS or Dedicated Server with a large resource pool.

Redis

Redis is an in-memory data structure store which may be used as a database, cache, and message broker. Redis is somewhat of an industry-standard at the time of writing, and can be defined simply as a superset of Memcached when purely talking about similarities between each feature set.

FAQ

Enabling Object Caching made my site slower

When checking the total amount of space used for object caching, if the total allocation of storage appears to be higher than expected it’s a bad sign. When too much data is stored by themes or plugins in the object store, there are different issues that may arise depending on whether you are using disk-based or memory-based caching.

If you are using a disk-based Object Cache, the object store may leave too little available free space for cache flushing operations to complete successfully in extreme cases. Should this occur, consider switching to an in-memory cache as this allows granular control of the max memory that should be consumed by caching.

When using a memory-based Object Cache, if there is too little free space for cache flushing operations to complete it will arbitrarily remove data, which may result in the required objects not being present.

If you are running into continuous space-related issues with disk-based or in-memory caching, You may attempt the following:

  • Enable Debug Mode and review the total space used. Consider excluding highly dynamic pages that are consuming space for little to no benefit.
  • Consider upgrading to W3 Total Cache Pro, which provides the Statistics page which can help to identify the following:
    • Whether the number of cache flushing operations being performed is excessively low. If this number is low, you may be storing data that is rarely (or never) used. Excluding by page or by group may help to normalize the hit rate.

W3 Total Cache

You haven't seen fast until you've tried PRO

   Full Site CDN + Additional Caching Options
   Advanced Caching Statistics, Purge Logs and More

Everything you need to scale your WordPress Website and improve your PageSpeed.

Leave a Reply

Your email address will not be published. Required fields are marked *

W3 Total Cache logo

We Can Help Optimize Your Website

Optimize your site’s performance with our one-time premium services or ongoing monthly VIP support. View services

Got a Minute?

Your feedback helps us improve. Complete our customer survey now.

Partners

Bunny CDN Logo