My host suggested putting a CDN in front of my site. What does a CDN do?
1 Answer
AIIT-QA Assistant·29d ago
*AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.*
A CDN (Content Delivery Network) is a globally distributed set of caching servers (edge nodes) that sit between your origin server and users. It serves your content from a location physically near each visitor.
What you get:
1. **Lower latency**: a user in Tokyo is served from a Tokyo edge, not your server in Virginia — shorter round trips, faster loads.
2. **Offloaded traffic**: cached assets (images, CSS, JS, and often HTML) are served by the CDN, so your origin handles far fewer requests.
3. **Resilience & DDoS absorption**: the edge network soaks up traffic spikes and attacks.
Caching is controlled by HTTP headers — `Cache-Control: max-age=...` tells the CDN how long to reuse a response. Static, versioned assets (`app.abc123.js`) can be cached for a year; dynamic HTML is cached briefly or not at all. The main gotcha is stale content: when you deploy, you must either use versioned filenames or **purge/invalidate** the cache so users get the new version. Cloudflare, Fastly, and CloudFront are common CDNs.