How CDN Works: From Edge Nodes to Global Delivery
A Content Delivery Network (CDN) is a geographically distributed group of servers that speeds up content delivery by caching it closer to users. Understanding how it works is the foundation for configuring it correctly. If you are new to the concept, start with our CDN beginner's guide.
1. Core Components and the Request Chain
1.1 The Origin
The origin is where content is actually stored — your web server or object storage. A CDN does not replace hosting; it caches copies of origin content. Origins usually live in one or a few data centers, far from most users, which is the main source of latency.
1.2 Edge Nodes
Edge nodes are cache servers distributed around the world. CDN providers place nodes at Internet exchange points (IXPs) and other high-speed interconnection locations so users can connect nearby. Edge nodes typically combine fast storage (SSD), load balancing, and network optimizations.
1.3 A Complete Request Chain
User → DNS resolution → nearest edge node → cache hit? serve directly
→ miss? fetch from origin → cache → serve
When a user visits your site, the browser first resolves the domain to the nearest edge node IP. If the node has a cached copy, it returns it immediately; otherwise it fetches from the origin, caches the response, and returns it. How often the origin is hit directly determines origin load and user experience.
2. Caching and Origin Fetch
2.1 Cache Hits and Misses
A cache hit means the edge node serves cached content directly — fast and free of origin bandwidth. A cache miss requires fetching from the origin, adding latency and cost. The hit ratio is the core metric for judging CDN configuration. See CDN cache hit ratio optimization and CDN cache strategy guide to improve it.
2.2 TTL and Cache Refresh
How long a cached copy lives is governed by TTL (Time to Live). Too short causes frequent origin fetches; too long delays updates. A common practice is long TTL for static assets (images, CSS, JS, fonts) and short TTL or active purging for HTML pages.
2.3 Controlling Caching with Response Headers
Whether a CDN caches content and for how long depends heavily on the response headers your origin returns. Here is a typical configuration:
# Static assets: long TTL + hashed filenames so stale caches expire naturally
location ~* \.(css|js|png|jpg|webp|woff2)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
}
# HTML: short TTL, let the CDN revalidate with the origin each time
location / {
add_header Cache-Control "public, max-age=60, must-revalidate";
}
The key is tiering, not a blanket rule: images, CSS, and JS get long TTLs and hashed filenames generated at build time so stale copies expire naturally; HTML gets a short TTL with must-revalidate so page updates propagate to the edge quickly. If your hit ratio will not climb, the first thing to check is whether the origin is returning a Cache-Control header at all.
3. Anycast and Global Delivery
3.1 What Is Anycast
Anycast lets multiple nodes in different locations share the same IP address. When a user requests that IP, the network routes traffic to the nearest node automatically. This is how CDNs achieve "connect nearby," and it is also the basis for high availability — when one data center fails, Anycast shifts traffic to others with little user-visible impact.
3.2 Internet Exchange Points (IXPs)
IXPs are high-speed interconnection points where different networks meet. Deploying nodes at IXPs lets CDN providers cut cross-network transit cost and latency. This is why node density and IXP coverage are treated as key measures of network quality.
4. What a CDN Really Buys You
4.1 Shorter Physical Distance
The closer content is to users, the lower the round-trip latency. Turning a cross-border request into a same-city one often saves tens to hundreds of milliseconds.
Here is a measurable example: a global English-language site whose origin lives in the eastern United States. Without a CDN, a European user's request must cross the Atlantic, with round-trip times (RTT) typically between 90-140ms. With a CDN that has edge nodes in Europe, RTT drops to 20-40ms, saving 150-300ms on first paint. For e-commerce, this latency maps directly to bounce and conversion rates — Google research shows that for every 1-second increase in mobile load time, conversion can drop about 20%. In other words, a CDN does not just save "a little speed"; it saves real orders.
4.2 Lower Origin Bandwidth and Cost
Most requests are answered by edge nodes, so the origin only handles a small share of traffic. This reduces bandwidth bills, especially for cloud servers billed by bandwidth.
4.3 High Availability and Redundancy
The distributed nature of a CDN provides natural redundancy. Load balancing and intelligent failover redistribute traffic when individual nodes fail, improving uptime.
4.4 Edge Security
Sitting at the network edge, a CDN can block DDoS attacks and malicious traffic before they reach the origin, and centrally manage TLS certificates. See CDN security features for details.
FAQ
- Can dynamic APIs be accelerated by a CDN? Yes, but you need the right approach. Caching everything will break login state and personalized content. The usual practice is to cache only public endpoints (article lists, pricing) with custom cache keys that account for region/language, while dynamic requests go to the origin. Providers like Cloudflare also offer edge functions (Workers) for dynamic logic.
- Can a CDN replace a cloud server? No. A CDN caches "copies," so the origin must stay online; it solves distribution distance, not compute or storage.
- What is a normal hit ratio? Above 90% is typical for static-heavy sites. Sites with personalized or dynamic content naturally have lower ratios, which is fine. The point is to compare against similar sites and watch trends, not chase a single number.
5. 16IDC View: Getting the Most from a CDN
A common mistake we see at 16IDC is assuming that simply joining a CDN equals "acceleration enabled." In practice, results depend on three layers:
- Origin quality: a slow origin or missing Cache-Control headers will drag down the whole experience when fetching;
- Cache strategy: sensible TTLs and cache keys per content type directly affect the hit ratio;
- Routing quality: node coverage, Anycast, and line-based routing should match where your users actually are.
For most small and mid-size sites, we recommend starting with a proven CDN acceleration setup, then gradually going deeper into CDN networking. Understanding the mechanism is not about rebuilding the wheel — it is about making accurate decisions when troubleshooting latency, evaluating providers, and controlling costs.
Source: https://www.cloudflare.com/learning/cdn/what-is-a-cdn/
References: Cloudflare cache documentation https://developers.cloudflare.com/cache/; MDN HTTP caching reference https://developer.mozilla.org/docs/Web/HTTP/Caching