---
topic: system-design
author: Crashtech Editorial
published: Nov 15, 2026 · read: 5 min
---

Content Delivery Networks Demystified: Edge Caching, Origin Offload and Traffic Shaping

How CDNs route requests to distributed edge locations, cache reusable responses, reduce origin load, and manage freshness without overclaiming latency gains.

– –
A coastal library sends books to neighborhood depots so nearby homes can retrieve common copies without every trip returning to the origin.
Conceptual editorial illustration; it does not depict a real system, event, or measurement.

A user far from an application’s origin may pay extra round trips for DNS, connection setup, TLS, and the request itself. Physics sets a floor on long-distance propagation time, but real latency also depends on peering, congestion, protocol behavior, and server work. A CDN can move cacheable content and selected computation closer to users; it cannot make every request local.

The Latency Problem and the Edge Solution

When a browser in Sydney requests an asset hosted in Virginia without a CDN, every TCP handshake packet, TLS negotiation round-trip, and HTTP payload traverses thousands of kilometres across undersea cables. A single TLS 1.3 handshake can take 200 to 300 milliseconds before a single byte of application data transfers.

Many CDNs use Anycast to advertise the same IP prefix from multiple locations. Network routing selects a path according to routing policy and topology; that path is not necessarily the geographically closest PoP. A CDN’s request path can then serve a cache hit or proxy to an origin:

MechanismWithout CDNWith CDN Edge
DNS ResolutionDirect to origin authoritative DNSGeoDNS or Anycast resolves to nearest edge PoP
Client connectionMay require network round trips to the originCan terminate at an edge location; improvement varies by route and protocol
Cache HitOrigin handles the requestEdge may return a reusable response without contacting origin
Cache MissFull WAN latencyEdge fetches via warmed, persistent backbone connection
Traffic surgeOrigin receives requests directlyEdge caching and provider controls may reduce origin load

Anatomy of a CDN Request: Hit, Miss, and Origin Shield

When a user requests an asset such as an image, video chunk, or JavaScript bundle, the request lifecycle follows a strict sequence:

  1. DNS Resolution: The client resolves the domain name. Anycast routing directs traffic to an advertised network endpoint according to routing policy; the selected PoP is not guaranteed to be geographically nearest.
  2. Edge Inspection: The edge server extracts the Cache Key (typically constructed from the scheme, host, path, and optionally normalized query parameters).
  3. Cache Hit: If a usable response is cached and fresh under the provider’s rules, the edge can return it without an origin fetch. Headers such as Age or provider-specific cache-status fields may expose cache behavior; X-Cache is not universal.
  4. Cache Miss and Shielding: If the asset is absent or stale, the edge proxies the request to an intermediate tier known as an Origin Shield or parent cache. The shield pools requests from dozens of regional edges, preventing a thundering herd from overwhelming the origin.
  5. Origin Fetch and Store: The origin responds with the payload and Cache-Control directives. The CDN stores the object locally and streams the response back to the client.

Modern CDNs do more than serve static media. With edge compute runtimes (such as V8 isolates), edges execute lightweight request rewrites, cookie validation, geolocation gating, and A/B test routing before traffic ever touches an origin service.

Cache Invalidation and Freshness Strategies

Operating a CDN introduces the distributed systems challenge of cache consistency. Serving stale JavaScript or broken CSS after a deployment breaks user workflows. Three primary strategies govern freshness:

1. Content Hashing (Cache Busting)

The most robust strategy for static bundles. Build tools generate file names containing a cryptographic digest of the contents (app.8f7e2a.js). The server configures immutable headers:

Cache-Control: public, max-age=31536000, immutable

Because file updates produce new URLs, assets never require manual edge invalidation.

2. Surrogate Keys and Cache Tagging

Dynamic resources (such as product catalogue pages or user profiles) cannot change URLs. CDNs allow origins to attach surrogate headers to responses:

Surrogate-Key: product-1294 category-audio brand-sony

When inventory updates, an internal worker dispatches an API purge specifying Surrogate-Key: product-1294. The provider invalidates matching cached objects according to its purge system. Propagation time and supported tag behavior vary by product and configuration; verify the provider’s documented guarantees before relying on a purge deadline.

3. Stale-While-Revalidate

To protect user experience during cache expirations, RFC 5861 allows edges to return an expired asset while asynchronously refreshing it in the background:

Cache-Control: max-age=600, stale-while-revalidate=60

A cache can serve a stale response within the configured stale window while revalidation occurs, reducing the chance that an expired object causes a slow response or origin stampede. This behavior must be supported by the cache and is not a fixed-latency guarantee.

Architectural Trade-Offs

Do

  • Use content-hashed filenames for static assets with long freshness lifetimes such as max-age=31536000, immutable when deployment and rollback practices support it.
  • Consider an origin-shield tier when request fan-in can reduce repeated origin fetches; validate the extra hop and provider-specific behavior.
  • Deliberately define cache keys, including which query parameters and headers affect the representation.

Don't

  • Do not cache personalized responses as shared content. Use appropriate private or no-store directives and verify the CDN’s cache policy.
  • Do not assume purge propagation is instantaneous or identical across providers; plan a rollback and freshness strategy.
  • Avoid forwarding headers that the origin does not need, but test connection reuse and correctness after changing the forwarded-header policy.

A CDN is a distributed cache and proxy layer whose benefits depend on what can be reused, how requests are routed, and how freshness is enforced. Measure cache hit ratio, origin request rate, tail latency, stale responses, and purge behavior on your actual workload. Treat Anycast, shielding, and DDoS controls as provider-specific mechanisms—not universal guarantees.

Advertisement

Frequently asked questions

How can a CDN improve performance for dynamic requests?

A CDN can terminate the client connection at an edge location and reuse connections to an origin, which may reduce connection setup and routing overhead. A cache miss still requires origin work, and the actual latency benefit depends on geography, provider routing, protocol settings, and the application.

What is the hardest part of operating behind a CDN?

Cache invalidation and state consistency. Purging cached objects across hundreds of globally distributed edge locations takes time and coordination. Teams avoid accidental stale data by using content-hashed asset URLs, aggressive cache-control headers, and granular cache tagging.

How can a CDN help with traffic surges or DDoS attacks?

A CDN can absorb cacheable traffic at its edge and use provider-specific network capacity and filtering to reduce load reaching an origin. Protection depends on the provider, plan, configuration, and attack; Anycast does not guarantee the nearest or safest route.

What is the difference between a Push CDN and a Pull CDN?

A Pull CDN fetches assets on demand from the origin upon the first cache miss and caches them according to HTTP headers. A Push CDN requires the application or CI pipeline to proactively upload content to edge storage prior to user requests.

Sources & further reading

/* Comments */