WordPress object cache: what it stores and when to bypass it

Wordpress Template Hierarchy.png

Written by

in

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

WordPress object cache: what it stores and when to bypass it
Photo: Rami via Wikimedia Commons (Public domain)

Most WordPress hosting dashboards now advertise Redis or Memcached object caching as a performance win. The pitch is simple: cache database query results in memory, serve pages faster. But object caching isn’t a blanket solution—some data should never be cached, and knowing when to bypass the cache is as important as enabling it.

What object cache actually stores

WordPress object cache holds the results of database queries and computed values that plugins and themes request repeatedly. When you call get_post(), get_user_meta(), or get_option(), WordPress checks the object cache first. If the data exists in memory, it skips the database entirely.

Common cached objects include post content, user metadata, taxonomy terms, option values, and transient API responses. Every WordPress page load fires dozens of these queries, so avoiding round-trips to MySQL saves milliseconds per request—milliseconds that compound across concurrent visitors.

Persistent object caching (Redis, Memcached) differs from the default in-memory cache that WordPress ships with. The built-in cache lasts only for a single page load; persistent cache survives across requests and is shared between all PHP workers. That’s why enabling Redis cuts database load even when traffic spikes.

When cached data goes stale

Object cache doesn’t automatically invalidate when you update a post, change a user role, or modify plugin settings. WordPress core handles cache invalidation for its own functions—editing a post flushes that post’s cache entry—but plugins and custom code don’t always clear related keys.

We’ve seen membership plugins cache user role checks, then fail to clear the cache when an admin upgrades a subscriber to a paid tier. The user still sees free-tier content until the cache entry expires or someone manually flushes it. Similarly, custom queries that bypass WP_Query often store results in cache but never invalidate them when underlying data changes.

Time-based expiration helps: most object cache implementations let you set a TTL (time to live) when storing a value. Setting a 15-minute TTL on a complex query means stale data lasts at most 15 minutes. But for user-specific or permission-gated content, even 15 minutes is too long.

Forcing a fresh lookup

WordPress doesn’t expose a universal “skip cache” parameter, but individual functions sometimes do. get_posts() accepts 'cache_results' => false to bypass object cache for that query. Custom code that uses wp_cache_get() and wp_cache_set() can simply skip the get() call and always hit the database.

When you need guaranteed fresh data—immediately after a user action, during checkout, or when displaying admin-only content—either skip the cache entirely or use a cache key that includes a timestamp or nonce. For example, appending the current user ID and a request timestamp to your cache key ensures no stale data leaks between users or page loads.

Another option: use transients with very short expiration for volatile data. Transients sit in object cache if available, but you control the lifespan explicitly. A 60-second transient for API rate-limit counters or session tokens gives you caching benefits without long-lived staleness.

Where bypassing makes sense

Bypass object cache for real-time inventory counts, user authentication checks, payment gateway callbacks, and any query that feeds conditional logic tied to money or access. Cache the surrounding page structure, but fetch the critical state fresh every time.

Also skip cache when debugging. If a plugin behaves inconsistently, flush object cache or disable it temporarily to confirm whether stale data is the culprit. Many hosting control panels (including those at BigScoots and other managed WordPress hosts) offer one-click cache flush buttons; use them liberally during troubleshooting.

For logged-in users, consider splitting cached and uncached requests. Serve anonymous visitors fully cached pages, and skip object cache for user-specific queries when someone’s logged in. This keeps the majority of traffic fast while ensuring account dashboards and member areas stay accurate.

Want more hosting and performance breakdowns? Subscribe to One Two Three Send—we publish operator-focused WordPress infrastructure guides every week.

The newsletter for newsletter operators

Daily field notes on deliverability, AI tools, hosting, and monetisation. No "top 10 plugins" filler — real tools, real numbers, real failures.

Other newsletters you might like

Irish Rugby Fans

The best Irish rugby updates, straight to your inbox — Six Nations, the Nations Championship and the provinces. Only when there's something worth reading.

Subscribe

Love California

Love California — in your inbox The Pacific Coast Highway, national parks, beaches, wine country and the best places to visit in California. One short email, every day.

Subscribe

Springbokfans

The best Springbok updates, straight to your inbox. Only when something worth reading actually happens.

Subscribe

Love Spain

Love Spain — in your inbox. Iconic cities, hidden pueblos and the best places to visit in Spain. One short email, every day.

Subscribe

Newsletters via the One Two Three Send network.  ·  Want your newsletter featured here? Click here