Skip to content

Object cache

The WordPress Object Cache is the second layer of caching that is encountered by requests that pass through the page cache and are routed to the origin servers. The Object Cache can be used to store the results of routine or expensive operations in memory so that subsequent requests can quickly access them. The Object Cache is commonly used for saving the results of database queries, remote HTTP requests, and any other operations that may be especially costly.

Each WordPress environment is provisioned with its own siloed Memcached cluster for persistently caching application-level data. The WordPress Object Cache is automatically configured to use these instances so that cache operations are routed to memory instead of the database.

The best candidates for caching are any data that will take longer to make than it takes to retrieve from the cache, such as slow database queries and remote calls. Keep in mind that cache operations are done over a local network, so there is some latency. Doing many cache operations during a request can add significant response time to the page.

Please note the following:

Transients

Transients are saved to the object cache on the VIP Platform instead of using the wp_options database table. The WordPress Transients API can still be used. However, functions like set_transient() and get_transient() are actually wrappers for their corresponding wp_cache_* functions  such as wp_set_cache() and wp_get_cache().

Transients can be managed using the wp transient  WP-CLI commands, as long as the the transient name is known. However the wp transient list command does not work as expected since it queries the database. Instead it will output an empty table and a warning.

Likewise, any plugins or custom code that query the database directly for transients will fail to retrieve the transient.

wp_cache functions

WordPress’ wp_cache_* functions can be used to add, set, get, delete, or replace cache objects in the persistent storage managed by Memcached. Memcached will evict cache objects when they expire or when the object cache is full.

Memcached employs a Least Recently Used (LRU) algorithm to manage the cache storage. The LRU determines which object(s)—if any—should be evicted from the object cache when a new object is being added.

The wp_cache_add and wp_cache_set functions default to no expiration. When a cache object has no expiration, it will persist indefinitely until either evicted by the LRU algorithm or when it is updated or deleted by another wp_cache_* function.

For more information about object caching in WordPress, review WP Cache Functions in WordPress.org’s Developer Reference.

Last updated: July 22, 2025

Relevant to

  • WordPress