Skip to main contentSkip to user menuSkip to navigation

CDN and Network Optimization

CDN optimization: caching semantics, Anycast, HTTP/2, HTTP/3, and QUIC protocols.

18 min readIntermediate
Not Started
Loading...

What is a content delivery network?

A content delivery network, or CDN, is a distributed data plane that answers eligible requests from edge locations near users. The edge can terminate connections, enforce request policy, cache reusable responses, and forward misses to a protected origin path.

A CDN matters because distance and shared origin capacity affect every global request. Serving a reusable object at the edge shortens the network path and removes work from the origin. The CDN does not make all traffic fast automatically: the response must be safe to reuse, requests must converge on a stable cache key, and the miss path must remain inside tested capacity.

The core invariant is representation safety. Two requests may share a cached response only when they are authorized to receive the same representation under the same freshness contract.

A CDN changes the request path, not the source of truth

A bounded CDN delivery path

A cache hit ends at the edge. A miss continues through a shield to the authoritative origin, then stores a response only when policy permits reuse.

Demand

Viewer

Resolve the hostname, negotiate a secure connection, and send an authorized request.

Nearby decision

Edge location

Normalize the key, apply edge policy, and serve a fresh or explicitly permitted stale object.

Miss protection

Regional shield

Coalesce repeated misses and limit fan-out from many edge locations to the origin.

Authority

Origin service

Generate or retrieve the canonical response and attach its cacheability and freshness policy.

Durable asset

Object store

Hold immutable versions and source objects behind a protected origin identity.

The origin remains authoritative even when the edge serves most reads. A cache purge changes derived copies; it does not replace the versioned source object, application state, or access-control decision.

The cache key is a correctness boundary

A cache key identifies the reusable representation. A typical key starts with scheme, host, path, and normalized query parameters, then includes only request dimensions that genuinely change the response.

Include a dimension when it changes the representation

  • Asset version: a content hash or release identifier separates changed bytes.
  • Language or encoding: include negotiated variants only when the response actually differs.
  • Tenant or authorization class: separate private representations before shared caching; many authenticated responses should remain private instead.
  • Query parameter: keep parameters that select content; drop tracking parameters that do not.
  • Device class: vary only when the server emits materially different assets, not merely because the header exists.

Fragmentation is the opposite failure

Adding cookies, full user-agent strings, request IDs, or irrelevant query parameters can create a unique key for nearly every request. The configured TTL may be long, yet effective hit rate remains low because equivalent requests never meet in the same entry.

Too little separation

Collision

Different authorized representations share one key. The failure is data leakage or incorrect content, not merely poor performance.

Too much separation

Fragmentation

Equivalent requests create many keys. Memory is diluted and misses transfer load to the origin.

Deliberate dimensions

Convergence

Safe equivalent requests map to the same entry, while private or genuinely different representations stay separate.

Trace failure through the actual delivery topology

An edge hit, a cold object, a fragmented key, and an origin timeout can all feel like “the CDN is slow.” The corrective action differs because each event activates a different path.

Keep data-plane and control-plane behavior separate

  • The data plane serves requests using currently active routing, cache, certificate, and policy state.
  • The control plane publishes configuration, invalidations, routes, and certificates to the data plane.
  • A control-plane delay should not automatically stop healthy cached delivery.
  • A purge or configuration rollout needs progress, failure, and rollback evidence across regions.
  • Regional failover must account for the cold-cache pressure created at the destination.

Cache-hit rate is an origin-capacity multiplier

For cacheable request rate R and hit rate H, the first origin-load estimate is:

origin requests per second = R x (1 - H)

At 100,000 requests per second, moving from a 95% hit rate to 90% doubles origin demand from 5,000 to 10,000 requests per second. Percentage points that look small on a dashboard can be a large absolute capacity event.

The origin model should include more than average request count:

  • peak demand and regional concentration;
  • cold-start and invalidation bursts;
  • shield hit rate and request coalescing;
  • origin latency, concurrency, and connection limits;
  • object size and egress bandwidth;
  • retries, timeout budgets, and stale fallback eligibility.

Plan the miss path as a production path, not an exceptional path. A CDN configuration that works only while the cache is warm has no safe recovery state.

Freshness is a product decision

HTTP caching distinguishes how long an object is fresh from what a cache may do after freshness ends. The correct policy depends on how costly stale data is and how quickly a new version must become visible.

Change the URL

Versioned immutable asset

Use a content hash in the path and a long freshness lifetime. Publishing new bytes creates a new key, so old versions can remain safely cached.

Check before reuse

Revalidatable document

Use validators such as ETag or Last-Modified so a stale entry can be confirmed without transferring the full body again.

Resilience window

Bounded stale response

Use stale-while-revalidate or stale-if-error only when an older representation remains safe during the stated window.

Invalidation is not the default versioning strategy

Purges are useful for emergency removal and bounded mutable objects, but they are distributed control-plane operations. They can be delayed, partially applied, rate limited, or issued with an incorrect scope. Prefer versioned URLs for immutable assets and measure purge completion when invalidation is required.

Build an explicit shared-cache policy

Network latency has multiple budgets

“Edge latency” is not one number. A viewer may pay DNS resolution, transport setup, TLS, request travel, edge processing, cache lookup, origin fetch, and response transfer. Connection reuse and modern transports can remove repeated setup work, but they cannot make a distant miss behave like a local hit.

  1. 1

    DNS

    Resolve and route

    Map the hostname to a healthy edge route. Respect TTL and failover behavior instead of assuming every resolver changes immediately.

  2. 2

    Connect

    Establish transport

    Negotiate TCP plus TLS or QUIC, then reuse the connection where possible. Loss and path changes affect the setup cost.

  3. 3

    Cache

    Make the edge decision

    Authenticate as required, normalize the key, check freshness, and choose hit, stale, revalidation, or miss behavior.

  4. 4

    Deliver

    Fetch and transfer

    Reach the shield or origin on a miss, then transfer bytes under the remaining deadline and populate only safe responses.

HTTP/2 multiplexes streams over one connection but can still suffer when packet loss blocks progress at the TCP layer. HTTP/3 maps HTTP onto QUIC streams so loss on one stream does not impose the same cross-stream transport blocking. Actual benefit still depends on network conditions, implementation, connection reuse, and workload.

Choose a CDN from workload constraints

Provider branding is less useful than a decision contract. Compare the behavior your workload must prove.

Delivery

Cache and origin control

Evaluate key normalization, shield behavior, request coalescing, stale policy, invalidation semantics, range requests, and origin authentication.

Edge boundary

Network and security

Evaluate TLS and protocol support, DDoS controls, web application policy, private connectivity, regional restrictions, and certificate operations.

Ownership

Operations and economics

Evaluate logs, real-time metrics, configuration rollout, rollback, support, egress pricing, request charges, and predictable failure behavior.

Run a representative test with your object sizes, cacheability mix, countries, protocols, and miss behavior. A published point-of-presence count or best-case latency does not prove that a specific request path meets its target.

Operate the edge with outcome evidence

Monitor the full distribution and the reason behind each outcome:

  • Cache outcomes: hit, miss, stale, revalidated, bypassed, and error by route and safe key dimensions.
  • Age and freshness: object age at serve time and time spent outside the intended policy.
  • Origin pressure: request rate, bytes, concurrency, shield efficiency, timeout, and retry amplification.
  • User latency: DNS, connection, time to first byte, and transfer time by region and protocol.
  • Correctness: authorization leakage tests, wrong-variant reports, purge completion, and stale-policy violations.
  • Resilience: regional failover time, cold-cache recovery, stale fallback use, and origin saturation.
  • Cost: edge egress, origin egress, request classes, invalidations, and compute at the edge.

Use a synthetic probe for known paths, but correlate it with real-user measurements and server-side cache status. One fast probe from a major city cannot represent a global network.

No quiz questions available
Could not load questions file
Spotted an issue or have a better explanation? This page is open source.Edit on GitHub·Suggest an improvement