A Content Delivery Network (CDN) is a geographically distributed network of proxy servers and data centers that speeds up content delivery by caching data closer to end users. By placing edge servers at the network perimeter, a CDN reduces the physical distance data must travel, decreasing latency and improving page load speeds. It also protects origin infrastructure by absorbing traffic spikes and filtering malicious requests before they reach your main server.
How it works
When a visitor requests a webpage or media file, DNS or Anycast routing directs the request to the nearest healthy edge server, also known as a Point of Presence (PoP). If the requested file is already stored in that node's cache (a cache hit), the edge server delivers it immediately. If the file is missing or expired (a cache miss), the edge server fetches it from your origin server, stores a copy locally based on cache rules, and sends it to the user.
Beyond static asset caching, modern CDNs accelerate dynamic traffic using persistent TLS connections, HTTP/3 support, and intelligent network routing. If an edge location experiences hardware failure or congestion, traffic automatically fails over to the next closest node. Depending on your architecture, you can use a commercial provider or deploy custom edge nodes—see our guide on VPS for CDN Node: Our Performance Data & Setup Guide for self-hosted setups.
- Reduces
latencyby shortening the round-trip time (RTT) between client and server. - Offloads significant bandwidth and CPU load from the origin server during traffic surges.
- Adds edge security layers, including DDoS mitigation, Web Application Firewalls (WAF), and automated TLS termination.
Example
CDNs rely on HTTP response headers from your origin server to determine how long an asset should remain cached at the edge. Below is a standard Nginx configuration block instructing a CDN to cache static assets for one week while allowing browsers to store them for one day:
location ~* \.(css|js|jpg|jpeg|png|webp|woff2)$ {
expires 1d;
add_header Cache-Control "public, max-age=86400, s-maxage=604800";
}
Here, s-maxage=604800 specifically targets shared caches like CDN edge nodes, overriding the shorter browser max-age directive.
What matters when choosing a CDN or hosting setup
- PoP geographic coverage: Edge locations must align with where your actual users are located, not just total global node counts.
- Cache purge speed: Look for sub-second global cache invalidation via API so updated content goes live immediately.
- Origin shield and bandwidth pricing: Egress fees from your origin host can add up quickly; an origin shield consolidates cache-miss requests through a single intermediate server. Compare options in our Best CDN Provider: Performance Data and Cost Comparison.
- Protocol and compression support: Ensure native support for Brotli compression, TLS 1.3, and HTTP/3 to maximize transfer efficiency.
Common mistakes
- Caching personalized or authenticated pages: Serving cached HTML containing user-specific session data or cookies can expose private information to other visitors.
- Ignoring query strings: Treating URLs like
style.css?v=1andstyle.css?v=2as identical without proper cache-key rules prevents updated assets from loading. - Exposing the origin IP address: If your origin server accepts direct traffic outside the CDN's IP ranges, attackers can bypass edge DDoS protection entirely.
FAQ
Does a CDN replace web hosting?
No. A CDN caches and delivers copies of your content, while web hosting stores your primary application, database, and source files on an origin server.
Are free CDNs good enough for production websites?
For small to medium sites, blogs, and standard business pages, free tiers often provide ample caching and basic DDoS protection. You can check real-world limits in our Free CDN for Website: Performance Benchmarks and Setup Guide.
Can a CDN speed up dynamic API responses?
While dynamic JSON responses usually cannot be cached, a CDN still improves speed by terminating TLS handshakes close to the user and routing traffic over optimized private backbones to your origin.