WordPress Β· Performance architecture

WordPress Caching Architecture: What to Cache, What to Exclude, and Why

Build a faster site with clear cache boundaries, deliberate exclusions, and reliable content invalidation.

WordPress caching works best when every stored response has a clear audience, a freshness limit, and an invalidation rule. Installing another optimization plugin cannot answer those questions. Without an architecture, several fast caches can repeatedly serve the wrong content.

The objective is to avoid unnecessary work while preserving correct behavior. Public articles, account pages, database objects, and static assets have different requirements. Treating them as one category creates stale pages, broken forms, and potentially exposed personal information.

1. Understand what each layer actually saves

Browser caching reuses downloaded responses on a visitor's device. A CDN or reverse proxy can reuse eligible responses across visitors. An origin page cache stores rendered output so a request can avoid regenerating the page. Object caching reuses application data while WordPress executes.

These layers complement one another. A shared HTML cache hit may avoid WordPress execution entirely. An uncached account page can still benefit from reusable application objects. Consequently, excluding a page from public HTML caching does not require disabling every cache beneath it.

WordPress's default object cache lasts only for the current request. Reuse across requests requires a persistent implementation, commonly provided through an object cache integration.[1] A Redis server alone does not establish that integration.

Diagram 1 Β· Cache layers and request paths
Request enters the delivery layer
BrowserReuses eligible local responses
CDN or proxyServes eligible shared hits
Origin page cacheReuses rendered public HTML

Browser β†’ CDN β†’ origin; a usable hit stops further work.

Miss or intentional bypass reaches WordPress
Object cache hitReuse data during execution
Object cache missRead the source and rebuild

Document which system owns each layer before changing settings. Otherwise, purging a plugin may leave an older CDN response untouched.

2. Cache public content with explicit variation

Published articles, documentation pages, and public landing pages are strong candidates for shared HTML caching. Their rendered output must be suitable for every visitor represented by the cache key.

A URL is not always enough to identify that audience. Language, currency, geography, or a negotiated representation can change the response. HTTP's Vary mechanism expresses relevant request header differences, but deployed cache support and configuration still need verification.[2]

Use a small, deliberate set of variants. Adding every cookie or request header to the key destroys reuse and makes invalidation harder. Conversely, ignoring a currency selector can show one shopper another market's price. Prefer explicit public variants and bypass personalized responses.

Choose the cache boundary by content behavior
ContentSuggested approachReason
Public article HTMLShared cache with publication purgeMany visitors receive equivalent output
Versioned CSS and JavaScriptLong browser and edge lifetimeChanged bytes receive a new URL
Customer account HTMLBypass shared page cachingIdentity changes the response
Expensive public query resultObject cache or transientReuse data without freezing the page
Preview or protected contentExclude from public cachingAccess depends on request context

3. Exclude stateful and private responses

Use conservative shared-cache exclusions for administration, login flows, password resets, previews, and authenticated personalized pages. Include custom routes introduced by membership, booking, and commerce extensions. An exclusion based only on familiar default paths can miss renamed endpoints.

WooCommerce specifically identifies Cart, Checkout, and My Account as pages that must remain dynamic because their content depends on the customer and cart.[3] Verify equivalent rules at the plugin, hosting proxy, and CDN layers. A correct origin setting cannot protect a response already served from an incorrectly configured edge cache.

Guest traffic is not automatically public traffic. Anonymous visitors can have carts, sessions, experiment assignments, or location-specific output. Evaluate relevant cookies and request semantics rather than treating the absence of a WordPress login cookie as sufficient proof.

Do not apply a blanket caching rule to REST or AJAX endpoints. Public read responses may be cacheable after deliberate analysis; authenticated reads and state-changing requests need different handling. Never let a shared cached result substitute for authorization.

4. Make headers express the intended policy

Cache-Control directives have distinct meanings. Private prevents shared cache storage but permits private caching. No-cache permits storage while requiring validation before reuse. No-store instructs caches not to store the response.[4] Choose deliberately rather than treating these terms as interchangeable.

For assets whose URL changes whenever their contents change, a long freshness lifetime with immutable can reduce repeat downloads and validation requests.[4] Do not apply that policy to a mutable stylesheet URL or account page.

Illustrative response headers for public, fingerprinted assets only
Cache-Control: public, max-age=31536000, immutable

Configure headers in the appropriate application, server, or CDN layer. Pasting this example into a WordPress content block does not change HTTP response headers. Inspect the actual response after deployment, including any overrides applied by hosting infrastructure.

Changing policy also does not automatically erase previously stored copies. Purge affected shared caches when correcting an unsafe rule, and account for browser copies that cannot be centrally purged through an ordinary CDN operation.

5. Cache data without making it authoritative

Object caches suit repeated data retrieval during application execution. Transients provide a convenient temporary storage API and can use the database or an external object cache depending on configuration. Their expiration is a maximum lifetime, not a promise that a value will remain available until then.[5]

Every cache read therefore needs a valid miss path. Regenerate from an authoritative source, validate the result, and store only the representation appropriate for the intended audience. Do not use a transient as the sole durable record of an order, permission, or payment state.

Design keys around the inputs that influence the result. A public related-articles calculation might depend on the article, language, taxonomy, and algorithm version. A single global key would mix unrelated results even if its expiration were short.

Distinguish empty results from failed lookups. Caching a legitimate empty list can reduce repeated work; caching a temporary upstream failure as an empty catalog can hide available content. Define separate handling for success, absence, and failure.

6. Treat invalidation as a dependency problem

Publishing an article can change its permalink page, homepage, category archive, feeds, and related-content blocks. Purging only the article URL leaves several visible representations stale. Map those dependencies and use the integrations supported by the chosen caching stack.

WordPress provides core cache-cleaning behavior such as clean_post_cache(), but that does not itself guarantee that every custom transient or external CDN page is purged.[6] Prefer supported content APIs and explicit invalidation for custom derived results.

Diagram 2 Β· Publishing changes several representations
Content update through the owning API
Core objectsInvalidate affected application data
Derived resultsExpire custom lists and fragments
Rendered pagesPurge affected origin and edge URLs

Each branch has its own invalidation owner and completion signal.

Subsequent requests rebuild eligible representations

Bounded expiration provides a fallback when an invalidation event is missed.

Avoid flushing everything after every edit. Broad purges create simultaneous misses and can overload the origin. Prefer targeted invalidation, controlled warming, and bounded rebuild concurrency. Where serving stale public content is acceptable, evaluate supported background revalidation rather than making every visitor regenerate the same result.

7. Verify correctness before celebrating hit rates

Test with separate browser profiles representing anonymous visitors and different authenticated users. Exercise login, logout, cart changes, publication updates, language switching, and form submission. Check the response body as well as cache status headers.

Forms deserve particular attention. WordPress nonces have limited lifetimes and are tied to context; they are not authorization mechanisms.[7] Long-lived HTML can contain expired tokens. Use a form integration designed for caching, an appropriate bypass, or a supported token refresh flow.

Measure cache eligibility, hit rates by layer, origin response time, database load, and invalidation delay. A high global hit rate can conceal a broken account route. Record bypass reasons so a legitimate private response is not mistaken for a performance defect.

Assign freshness budgets to the complete response path. If an origin page cache rebuilds from stale derived data, a fresh CDN copy can still contain outdated information. Coordinate data expiration, page expiration, and purge propagation instead of judging freshness from the outermost cache alone.

Consider an editorial site changing an author's display name. The author page, article bylines, archive cards, and structured data may all need updates. Record those dependencies in the implementation rather than relying on an editor to remember several purge buttons. Verify the change as an anonymous reader after publishing.

For deployments, connect asset versioning to generated HTML. Keep older asset files available while cached pages can still reference them. Removing yesterday's bundle immediately can break visitors who receive otherwise valid cached markup. A rollback also needs compatible assets, not merely the previous PHP files.

Give one team ownership of cache policy across infrastructure and application settings. Document the intended audience, variation dimensions, freshness tolerance, and invalidation trigger for each response category. This makes future plugin changes easier to assess and reduces accidental conflicts between performance settings maintained by different people during routine releases and troubleshooting.

Finally, test cold-cache behavior and recovery after a purge. WordPress must remain functional when cached data disappears. A sound architecture accelerates correct responses, preserves personalized boundaries, and makes stale content diagnosable instead of encouraging another indiscriminate cache clear.