Glossary Term
CDN (Content Delivery Network)
On this page
TL;DR: A CDN is a fleet of reverse proxies spread across regions that cache your responses and serve them from the nearest edge, so most requests never reach your origin server.
A content delivery network (CDN) is a geographically distributed set of caching reverse proxies. Browsers connect to a nearby edge server; on a cache hit the edge answers directly, and on a miss it fetches from your origin, stores the response according to its caching headers, and returns it.
What a hit looks like
HTTP/1.1 200 OK
Content-Type: text/css
Cache-Control: public, max-age=31536000, immutable
Age: 4312
CF-Cache-Status: HIT
Age is the number of seconds the response has sat in a shared cache, as defined by RFC 9111. The status header is vendor-specific: Cloudflare uses CF-Cache-Status, CloudFront uses X-Cache: Hit from cloudfront plus X-Amz-Cf-Id, and other vendors use their own X-Cache variants. No Age on a response you expected to be cached usually means a miss or a bypass.
Non-obvious facts
- A CDN follows your caching headers, then its own rules.
Cache-Control: s-maxageapplies to shared caches such as CDNs only, so you can give the edge an hour while browsers revalidate every time.privateandno-storekeep a response off the edge. - HTML is often not cached by default. Cloudflare, for example, caches by file extension and does not cache HTML unless a cache rule says so. If pages are slow, check this before blaming the network.
Varyfragments the cache.Vary: Accept-Encodingis fine;Vary: User-AgentorVary: Cookiecan drop the hit ratio to near zero because every distinct value gets its own entry.- A CDN adds another place to debug. A 502 or 504 may come from the edge, not your server. Compare headers such as
Server,ViaandCF-Raywith a request made directly to the origin. - Purging is not instant everywhere. Invalidations take time to propagate across the network, so versioned asset URLs are more reliable than purging.
Go deeper
Frequently asked questions
What does a CDN do?
It terminates connections close to the user and serves cacheable responses from edge servers, falling back to your origin on a miss. It also absorbs traffic spikes and TLS work.
How can I tell if a response came from the CDN cache?
Look for Age greater than zero and a vendor header such as CF-Cache-Status: HIT on Cloudflare or X-Cache: Hit from cloudfront on CloudFront.
Does a CDN cache HTML?
It depends on configuration. Many CDNs cache static file extensions by default and pass HTML through unless Cache-Control or a rule says otherwise.
Is a CDN the same as a reverse proxy?
A CDN is a reverse proxy that is geographically distributed and caches. Every CDN edge is a reverse proxy; not every reverse proxy is a CDN.
Sources
Related
X-Cache Header
Learn how the X-Cache header indicates cache hit or miss status from CDNs and proxies. Debug caching issues and verify CDN configuration with this header.
Cache-Control Header: Directives, Examples and CDN Behavior
Cache-Control directives explained: max-age, no-cache vs no-store, s-maxage, stale-while-revalidate, immutable, with nginx, Cloudflare and Next.js examples.
Age Header
Learn how the Age header indicates how long a response has been cached in seconds. Understand cache freshness calculations and CDN behavior.
Reverse Proxy
A reverse proxy sits in front of origin servers and forwards client requests to them. Learn the headers it adds, nginx proxy_pass pitfalls and 502/504 causes.