TechnologyNetworking

How a CDN actually delivers content, from DNS to the edge cache

How content delivery networks route users to nearby edge servers, decide what to cache, invalidate stale content, and shave hundreds of milliseconds off page load.

MAMichael Adeyemi — Senior Technology Writer, MSc, Distributed SystemsPublished 14 September 2025Last reviewed 9 January 20268 min readIntermediate1,600 words

Fact-checked by Dr. Rina Halvorsen, Editor-in-Chief (PhD, Cognitive Science) · 5 primary sources cited · how we review

Engraved illustration of a globe with content radiating outward from distributed nodes

In short

A content delivery network works by placing copies of content on servers physically close to users and routing each request to the nearest healthy one, rather than sending every request back to a single origin server. The gain comes from cutting round-trip distance and from serving cached responses without touching the origin at all. Getting this right depends on which content is cacheable, how invalidation is handled, and how routing decisions are made in milliseconds.

A CDN is often described loosely as 'a network that makes websites faster', which is true but hides the actual mechanism. A CDN is a distributed set of servers, called edge servers or points of presence, that hold copies of an origin server's content and are positioned so that most users are physically and topologically close to at least one of them. Speed improves because two of the largest costs in a web request — network distance and origin server load — are both reduced.

Why distance is the dominant cost

Light in fibre travels at roughly two-thirds the speed of light in a vacuum, which puts a hard floor under network latency regardless of bandwidth. A round trip between London and Sydney cannot physically complete in under about 140 milliseconds no matter how fast either connection is provisioned, because that is the minimum time for a signal to make the return journey at that distance. A CDN cannot break this limit, but it can make the distance much shorter by serving from a point of presence in or near Sydney instead of routing every request back to a single origin in London.

Modern CDN operators run points of presence numbering in the hundreds across many countries, each holding a partial or full cache of frequently requested content. The practical effect for a typical user is that a static asset request that would otherwise cross a continent instead travels a few kilometres to a metro-area edge node.

How a request finds the nearest edge server

Anycast IP routing

Many CDNs advertise the same IP address from multiple physical locations using BGP anycast. Internet routers naturally forward a packet toward whichever advertising location is topologically nearest according to normal routing metrics, so users in different regions transparently reach different physical servers while addressing the identical IP address. No per-user configuration or redirection is required; the routing fabric of the internet does the selection.

DNS-based routing

The alternative or complementary approach uses DNS: the CDN's authoritative name servers inspect the resolver making the query (a reasonable proxy for the end user's location) and return a different IP address depending on where that resolver appears to be. This allows routing decisions informed by real-time load and health data, not just static network topology, at the cost of depending on DNS resolvers reporting accurate client location via mechanisms such as EDNS Client Subnet.

Anycast versus DNS-based edge routing
PropertyAnycast routingDNS-based routing
Decision made byInternet routing (BGP)CDN's authoritative DNS servers
Granularity of load balancingCoarse; follows network topologyFine; can factor in real-time load
Failover speedFast once BGP reconvergesLimited by DNS TTL caching
Complexity to operateRequires BGP infrastructure at each PoPRequires accurate client-location signals

What actually gets cached, and for how long

Not all content is safe to cache. Static assets — images, stylesheets, fonts, versioned JavaScript bundles — are ideal candidates because they are identical for every user and rarely change. Personalised or transactional responses, such as a shopping cart page or an authenticated dashboard, generally must not be cached at the edge without careful configuration, because doing so risks serving one user's private data to another.

Cache behaviour is controlled primarily through HTTP response headers set by the origin: Cache-Control with directives such as max-age and public or private, along with validators like ETag and Last-Modified that let an edge server ask the origin 'has this changed?' without re-downloading the full response. A well-tuned origin sets long max-age values on immutable, versioned assets (often using a content hash in the filename) and short or no caching on dynamic HTML.

  • Cache-Control: public, max-age=31536000, immutable — appropriate for a hashed, versioned static asset that never changes once published.
  • Cache-Control: no-store — appropriate for responses containing sensitive per-user data that must never be cached anywhere.
  • ETag validation lets the edge send a conditional request and receive a lightweight 304 Not Modified instead of the full body when content is unchanged.
  • Vary: Accept-Encoding (and similar) tells the cache that responses differ by request header, so it must store separate copies per variant.

Cache hit ratio and why it is the key metric

A cache hit means the edge server answered the request directly from its stored copy; a cache miss means it had to fetch fresh content from the origin, incurring the full round-trip latency the CDN exists to avoid. The cache hit ratio — the proportion of requests served as hits — is the single number that best predicts both user-perceived speed and origin server load, since every miss both slows that request and adds load the origin must absorb.

Illustrative effect of cache hit ratio on average response time

Milliseconds, illustrative figures for a typical static asset workload

Figures are illustrative, assuming an edge hit costs roughly 20 ms and a miss requiring an origin round trip costs roughly 180 ms; real ratios and costs vary by CDN, geography and content type.

Invalidation: the hardest part of caching

Once content is duplicated across hundreds of edge locations, updating it becomes a coordination problem. If an origin publishes a corrected price or a security fix, every edge holding a stale copy needs to either purge that copy or be prevented from serving it further. CDNs typically offer explicit purge APIs to invalidate specific URLs or tags on demand, alongside the passive expiry that happens automatically once max-age elapses.

  1. Time-based expiry: content is simply treated as stale once its max-age has elapsed, with no action needed from the origin.
  2. Explicit purge: the origin calls the CDN's API to invalidate a specific URL or a tagged group of URLs immediately after publishing a change.
  3. Cache-busting via the URL itself: embedding a content hash or version number in the filename means a changed file is simply a different URL, sidestepping invalidation entirely for immutable assets.
  4. Stale-while-revalidate: the edge serves the last known copy immediately while fetching a fresh one in the background, trading brief staleness for consistently fast responses.

Using a CDN

Pros

  • Cuts network round-trip distance for most users, which is often the single largest fixed component of page load time
  • Absorbs traffic spikes and reduces load on the origin server, improving resilience under sudden demand
  • Provides a natural point to add security features such as DDoS mitigation, TLS termination and web application firewalling
  • Enables efficient global delivery of large static assets like images and video without provisioning origin infrastructure worldwide

Cons

  • Adds an extra layer to reason about when debugging content that appears stale or inconsistent across regions
  • Misconfigured caching of personalised or sensitive responses can leak one user's data to another
  • Introduces a dependency on a third-party operator's uptime and configuration correctness
  • Cache invalidation across hundreds of distributed nodes is inherently harder to reason about than a single origin cache

Key points

  • A CDN speeds up delivery mainly by shortening network distance and by offloading repeat requests from the origin.
  • Requests are routed to the nearest healthy edge server via anycast IP routing, DNS-based routing, or a combination of both.
  • Cache-Control headers and validators like ETag determine what is cached, for how long, and how staleness is checked.
  • Cache hit ratio is the metric that most directly predicts both speed and origin load.
  • Invalidation across many distributed edge nodes, not caching itself, is usually the hardest operational problem.

Origin shielding and the multi-tier cache hierarchy

Large CDN deployments rarely rely on a single tier of edge servers talking directly to the origin. Instead, a smaller set of 'shield' or mid-tier caches sit between hundreds of edge points of presence and the origin itself. Every edge node in a given region is configured to fetch a miss from its assigned shield node rather than from the origin directly, so that when a piece of content goes viral, the origin only ever sees one request per shield location rather than one request per edge location, even though thousands of end users are being served simultaneously.

This origin shielding pattern is what allows a modestly provisioned origin server to sit behind a CDN handling enormous request volumes without being overwhelmed by cache-miss traffic. It also concentrates the caching of rarely requested 'long tail' content at the shield tier, since a single edge location might see a specific rare asset only once, while its shield may see enough aggregate demand across many edges to justify keeping that asset cached.

TLS termination and the security role of the edge

Because a CDN edge server is the first point of contact for a client's connection, it is also the natural place to terminate TLS, the encryption layer behind HTTPS. Terminating TLS at the edge means the expensive cryptographic handshake happens close to the user, which shortens the number of round trips needed before any content can be exchanged, and it gives the CDN operator visibility to apply security filtering before traffic ever reaches the origin.

This is also why CDNs are a common home for web application firewalls and DDoS scrubbing: malicious or excessive traffic can be absorbed and filtered at hundreds of distributed edge locations, each handling only a fraction of the total attack volume, rather than concentrating the full load on a single origin data centre. The trade-off is that the CDN operator now holds the TLS private key material, or a delegated equivalent, which is a meaningful trust decision worth understanding before adoption.

Connection reuse and protocol negotiation

A further, less visible benefit of edge termination is connection reuse. Once a client has completed a TLS handshake with a nearby edge server, that connection can be kept open and reused for many subsequent requests, and the edge server typically maintains its own long-lived, already-warmed connections back to the shield or origin tier. The client never pays the cost of a fresh handshake per request, and the CDN can independently choose to speak HTTP/2 or HTTP/3 to the client regardless of what protocol the origin itself supports.

Typical layers between a user and the origin server
LayerRoleTypical scope
Edge PoPTerminates client connection, serves cache hits, applies security filteringMetro area, closest to the user
Shield / mid-tier cacheAbsorbs misses from many edges, protects origin from duplicate requestsRegional, one per origin region
OriginSource of truth for all content, handles genuine cache misses and dynamic requestsSingle location or small origin cluster

Sponsored video

Advertisement

Checking for a video ad…

Frequently asked questions

Sources

About the author

Michael Adeyemi — Senior Technology Writer

Michael writes Inquro's computing and web-infrastructure coverage. He worked for eight years as a platform engineer on high-traffic content systems before moving into full-time technical explanation, and he still prototypes every measurement described in his articles before publishing the numbers.

Qualifications
  • MSc, Distributed Systems — University of Manchester
  • BEng, Computer Engineering — University of Lagos
Experience
  • Eight years as a platform engineer on high-traffic content delivery systems
  • Four years writing standards-based technical documentation
Subject areas:
Web performance, Networking, Systems architecture

Reviewed for factual accuracy by Dr. Rina Halvorsen, Editor-in-Chief (PhD, Cognitive Science), on 9 January 2026.

Structure, claim strength and whether an explanation actually answers the question a reader arrived with.

Inquro articles are commissioned, sourced, reviewed and re-checked under a published editorial policy. Corrections are made in place and dated — write to editorial@inquro.example if you find an error.

Related explainers

More from Technology and connected clusters across the full library.

TechnologyNetworking

How DNS resolution works, step by step

A complete walkthrough of DNS resolution: the recursive resolver, root, TLD and authoritative servers, caching layers, TTL behaviour, and why DNS is so often the hidden cause of slow first loads.

Michael AdeyemiUpdated 15 July 202611 min
TechnologyWeb Performance

Core Web Vitals explained: what LCP, INP and CLS actually measure

A practitioner's guide to Core Web Vitals: what Largest Contentful Paint, Interaction to Next Paint and Cumulative Layout Shift measure, how field data differs from lab data, and how to diagnose each metric.

Michael AdeyemiUpdated 28 July 202611 min
TechnologyNetworking

What actually happens between pressing Enter and seeing a page

A complete walk-through of the pipeline behind a single web request: DNS resolution, TCP and TLS setup, the HTTP exchange, and browser parsing and rendering, with the latency each stage typically adds.

Michael AdeyemiUpdated 14 February 20269 min
TechnologyNetworking

How public key infrastructure turns a key pair into verifiable identity

How public key infrastructure links cryptographic keys to real-world identity through certificates, certificate authorities and trust chains, and how revocation, transparency logs and automation keep the system trustworthy at internet scale.

Michael AdeyemiUpdated 11 April 20269 min

Keep reading

Definitions used here

Go deeper