A CDN can deliver a static image from a nearby location without asking the application for it. An account page or product API is harder. Its response may change with inventory, geography, a session cookie or a recent write. Caching that response at the edge can reduce latency and origin load, but the same mechanism can serve the wrong version—or the wrong user’s data—if the sharing boundary is unclear.
The useful question is not whether the page is “dynamic.” It is whether many requests can safely share the same response for a defined period. That makes edge caching a decision about response identity and acceptable staleness before it is a CDN configuration choice.
Begin with the responses, not the CDN
A sensible baseline serves static assets through a CDN and lets application responses reach the origin. Measure where latency accumulates: network distance, origin queueing, application work, database access and response size. Moving a response to the edge helps most when it avoids repeated origin work or a long round trip for many users. It cannot repair a slow write path, an inefficient database query on every cache miss or a response that is unique to every request.
Consider a public catalog page assembled from a database. The page may be generated dynamically, yet thousands of visitors in one market could see identical content between catalog updates. It is a candidate for shared caching. An authenticated account balance is also generated dynamically, but requests cannot safely share one response across accounts. Calling both “dynamic content” hides the architectural distinction.
For each route, write down which requests may share an identical response, how old that response may be, and what event makes it invalid. If any answer is unknown, keep the route at the origin.
Choose the narrowest useful caching boundary
Edge caching does not require caching an entire site. Start with a response class whose sharing rules are easy to prove: public article pages, public catalog records, documentation or anonymous API reads. Keep authenticated pages, checkout, account data and mutations out of the first policy. A later route can be admitted only when its identity and update rules are explicit.
| Pattern | Best fit | What you gain | Main failure mode |
|---|---|---|---|
| Origin only | Per-user or immediately consistent responses | One authoritative execution path | Origin latency and load rise with requests |
| Short-lived shared edge cache | Public responses with bounded staleness | Fewer origin requests and nearer delivery | Stale or incorrectly shared responses |
| Edge cache with targeted invalidation | Public responses updated by identifiable events | Longer reuse with faster corrections | Missed purge paths and uneven propagation |
| Personalization after shared delivery | Mostly common page with a small private portion | Shared base response without sharing private data | Extra client requests and mixed-version rendering |
The last pattern separates a public shell from private data fetched through an uncached or user-scoped path. It is useful only when the public portion is substantial and the extra round trip does not erase the latency benefit. Splitting a page purely to achieve a high cache-hit ratio can make rendering and failure handling harder.
This boundary differs from a database cache or read replica. Those are tools for reducing database pressure inside the application; the cache versus read replica decision does not determine whether an HTTP response can be shared with another visitor. A system may need both layers, either one or neither.
The cache key is part of the data model
A shared cache decides whether two requests refer to the same object by constructing a cache key. The path alone may be insufficient. A language header, a currency parameter or a market code can change the response. If such a dimension is omitted from the key while the origin varies its output, one visitor can receive another variant. For private responses, the consequence can be a data exposure rather than a cosmetic error.
The opposite mistake is putting every header, cookie and query string in the key. Tracking parameters and unique session identifiers then create nearly one object per request. The edge stores many variants but does little useful work. AWS’s cache-policy documentation describes how selected headers, cookies and query strings define the cache key; those selections directly affect reuse.
For each candidate route, identify the smallest set of inputs that changes the public representation. Normalize or remove irrelevant query parameters. Do not put authorization tokens in a shared key as a shortcut for private caching: that multiplies variants and turns secret-handling into a cache-policy problem. If a response depends on identity or permission, default to bypass until its confidentiality model has been designed and tested.
HTTP also has explicit shared-cache semantics. RFC 9111 defines directives including private, no-store and s-maxage, and places conditions on storing responses to requests with authorization. Provider rules can override an origin’s intent: a configured minimum TTL, for example, may cause a CDN to cache despite restrictive response headers. Review the effective CDN policy and the origin response together, especially around login and error routes.
A cache key is a statement that requests with the same key may receive the same bytes. Treat that statement as a correctness and security claim, not a tuning parameter.
Bound staleness before adding purges
A short shared TTL is usually the simplest first design. It bounds how long a changed public response may remain fresh without requiring an event-driven invalidation system. The right interval comes from the consequence of staleness: an editorial page can often tolerate a delay that a price, seat count or operational status cannot. Do not assign one TTL to every route because the CDN accepts a site-wide default.
Targeted purge is justified when updates must become visible faster than an economical TTL permits. It adds a new delivery path: the write must succeed, the invalidation event must be emitted, the right keys must be identified, and the purge must reach the relevant cache locations. Failure at any step can leave old content serving after the origin has changed. Versioned URLs or immutable asset names avoid some purges for assets; mutable API and page URLs still need an explicit freshness policy.
Serving stale while revalidating can soften expiry spikes on public, staleness-tolerant routes. Serving stale during origin failure may improve continuity, but it changes the failure contract: users may see an older state precisely when the application cannot confirm a newer one. Google Cloud’s stale-content guidance illustrates this behavior. Apply it selectively; a stale maintenance notice or product description is different from a stale account entitlement or transaction result.
Cache invalidation must include rollback. If a bad release changes the public representation, restoring code at the origin may not change copies already at the edge. Keep a way to bypass or purge the affected route, and test that emergency path. The operational threshold for longer TTLs is therefore not merely a low update frequency; it is confidence that wrong content can be withdrawn.
Watch what happens on a miss
A cache hit avoids origin work. A miss still traverses the origin path, and that path can become more fragile if capacity planning assumes every request will hit. A new deployment, key change, broad purge or traffic spike can make many locations request the same object at once. Different CDN products offer request coalescing or origin shielding, but their behavior depends on configuration and failure mode. Validate the miss path instead of treating those features as universal protection.
Measure cache-hit ratio by route and by traffic volume, not only as a site-wide average. A high ratio for tiny assets can conceal an uncached expensive API; a modest ratio for a costly public endpoint can still remove substantial origin compute. Track origin request rate, miss latency, response age, purge lag, error rates and the dimensions of the key. For private routes, test with two distinct users and sessions to prove isolation; production metrics cannot substitute for that test.
Application deployments need to preserve compatibility with cached responses. If a new client expects a field that older edge responses lack, a rolling release can fail even while the origin is healthy. Version the representation or keep consumers tolerant during the overlap. The same principle applies to browser caches and any intermediate proxy; the edge is one layer in a chain, not the sole keeper of state.
A cache changes the traffic shape reaching the origin. Capacity and incident drills must include cold caches, broad invalidations and an edge bypass.
Count the full cost and decide route by route
Edge caching can reduce application compute, database reads and origin data transfer while improving response time for users far from the origin. It also adds CDN requests, storage and egress charges, invalidation operations and engineering time. If the workload is already served near its users, responses are rarely reused, or personalized variants explode the key space, the incremental saving may be small. Compare costs per successfully served request, including the origin work avoided, instead of treating a better hit ratio as the financial objective.
Start by selecting one high-volume public route with costly or distant origin delivery and a defensible staleness budget. Define the response variants, set a short shared lifetime, and keep authenticated and mutation routes bypassed. Measure latency and origin load before and after. Expand only when the observed benefit exceeds the added policy and incident burden. Add targeted purge or stale serving when a concrete update or availability requirement earns it.
Do not let the edge become the only place where the application is fast. If the uncached path is unusable, a purge or cold start becomes an outage. Edge caching is a strong scaling layer when many visitors legitimately share a response and the origin remains capable of serving misses. The final decision belongs to each response class: who can share it, how long it can be wrong, and how the system behaves when the cache is empty.
Cache a dynamic response at the edge only when its sharing boundary, staleness budget and miss path are explicit—and measured against the cost of keeping it at the origin.
Continue exploring response paths
Follow the request from edge delivery into application capacity, data access and access boundaries.
Cloud strategy, architecture and infrastructure decisions explained without vendor noise.
