Content delivery network (CDN)
A geographically distributed network of servers that caches and serves website assets from locations near the user, reducing load time and origin server load.
Also known as: CDN, content distribution network
A content delivery network (CDN) is a network of servers distributed across many geographic locations that caches and delivers website content to visitors from a server near them. CDNs reduce the distance data must travel between server and user, improving load times and reducing the load on the origin server.
How a CDN works
When a website is configured to use a CDN, requests for the site’s assets (HTML, images, CSS, JavaScript, video) are routed through the CDN. On the first request from a given region, the CDN fetches the asset from the origin server and caches it at an edge location near the requesting user. Subsequent requests for the same asset from the same region are served directly from the edge cache, without contacting the origin.
This works because most website assets are the same for every visitor, an image of a product, a CSS file, the homepage HTML, and can be safely cached and reused.
What a CDN typically caches
CDNs are most effective for content that does not vary per visitor:
- Images and media files
- CSS and JavaScript files
- Static HTML pages
- Fonts
- Video segments
- Downloadable files (PDFs, zip files, software installers)
Personalized content (logged-in dashboards, account pages) is generally not cached, though some CDNs offer per-user caching strategies.
Why CDNs improve performance
Three main reasons:
- Reduced latency. Data travels a shorter physical distance, so round-trip times are lower
- Reduced origin load. Fewer requests reach the origin server, which can handle more traffic
- Optimization at the edge. Many CDNs apply image compression, minification, and protocol upgrades (HTTP/2, HTTP/3) on the way out
For a global audience, a CDN can reduce page load times by hundreds of milliseconds compared to serving from a single regional server.
Common CDN providers
- Cloudflare, large free tier, integrated security and DNS
- Fastly, performance-focused, popular with media and ecommerce
- Amazon CloudFront, part of AWS
- Akamai, long-established enterprise CDN
- Bunny.net, lower-cost alternative
- Vercel and Netlify include built-in CDN as part of their hosting platforms
CDN features beyond caching
Modern CDNs typically offer additional functionality:
- DDoS protection. Absorbing or filtering malicious traffic
- Web application firewall (WAF). Blocking malicious requests
- SSL/TLS termination. Handling HTTPS at the edge
- Image optimization. Automatic format conversion (WebP, AVIF) and resizing
- Edge functions / edge workers. Running code at the edge to customize responses
- Bot management. Distinguishing legitimate traffic from automated scrapers
How a CDN is set up
There are two common configurations:
- DNS-based (reverse proxy). The site’s DNS is configured to point at the CDN, which proxies all traffic. Common for Cloudflare’s reverse-proxy setup.
- Subdomain-based. Static assets are served from a separate subdomain (e.g.,
cdn.example.com) that points to the CDN, while the main site is served from origin. Common for image-heavy sites where only assets need acceleration.
Cache invalidation
When content changes, the cached version at the edge needs to be updated. CDNs handle this in several ways:
- TTL (time to live). Cached content expires after a defined period (minutes, hours, days)
- Manual purge. Operators trigger an explicit cache invalidation
- Cache tags. Content is tagged so related items can be invalidated together
- Versioned URLs. Each new version of an asset uses a new URL (e.g.,
app.v3.js), which is treated as a fresh asset
Common misconceptions
- “A CDN replaces hosting.” The origin server still hosts the canonical content. The CDN caches and delivers it.
- “All sites benefit equally from a CDN.” Sites with mostly static content and a global audience benefit most. Locally-targeted sites with mostly dynamic content see smaller gains.
- “CDNs are only for large sites.” Free tiers from Cloudflare and others make CDN use practical for sites of any size.