CDN
A CDN (content delivery network) is a network of servers distributed across many locations that caches a website's content and serves it from the server closest to each visitor, instead of a single origin server potentially thousands of kilometers away.
What is a CDN?
Without a CDN, every visitor's request travels all the way to a website's origin server, wherever it is hosted, and back. A CDN places copies of static content, images, CSS, JavaScript, and sometimes full pages, on servers ("edge nodes" or "points of presence") spread around the world, so a visitor in Tokyo gets served from a node in Tokyo rather than from a server in Paris. The result is lower latency, faster page loads and less load on the origin server itself.
The gain is largest for sites with visitors spread across multiple regions or countries. A site hosted in Europe with only European visitors gets a smaller benefit from a CDN than the same site with meaningful traffic from North America or Asia, since the physical distance a request would otherwise travel is what the CDN removes.
How a CDN works
- A visitor requests a page; DNS routes the request to the nearest CDN edge node instead of the origin server.
- If that node already has a cached copy of the requested content, it serves it directly, a "cache hit".
- If not, the node fetches the content from the origin once, caches it, and serves it, a "cache miss" the first time only.
- The origin server is only hit for uncached or dynamic content, and for periodic cache refreshes.
A cached asset typically ships with cache headers such as:
Cache-Control: public, max-age=31536000, immutableWhat a CDN typically caches
- Images, fonts and videos.
- CSS and JavaScript files.
- Fully rendered static pages, for sites that support full-page caching.
- API responses, in some setups, when the underlying data changes infrequently.
CDN vs web hosting vs edge computing
| Aspect | CDN | Web hosting | Edge computing |
|---|---|---|---|
| What it does | Caches and serves static content from many locations | Runs and stores a site's origin files and databases | Runs application logic close to the visitor, not just cached files |
| Solves | Latency for content already generated | Where a site's core files and data live | Latency for logic that must run per request |
| Example provider | Cloudflare, Fastly | A hosting platform or cloud provider | Cloudflare Workers, edge functions |
| Needed by | Almost every production site | Every site, without exception | Sites with per-visitor logic (personalization, A/B tests) at the edge |
Best practices and common pitfalls
A CDN needs correct cache headers to be useful; content cached without an expiration strategy either goes stale (visitors see outdated content) or barely gets cached at all. Purging the cache after every deploy, rather than only when content actually changes, adds unnecessary load back onto the origin. A CDN also does nothing for a slow backend or an unoptimized database query, since dynamic, uncacheable content still hits the origin on every request. Most CDNs also include a layer of DDoS protection and a web application firewall, which is often the real reason a business adopts one beyond speed.
Impact on Core Web Vitals and SEO
A CDN directly improves metrics that feed into Core Web Vitals, particularly Largest Contentful Paint, by cutting the network time needed to fetch a page's heaviest assets. Since Google factors page experience into ranking, a faster-loading site through a CDN has a real, if indirect, SEO benefit, on top of the more immediate benefit of a lower bounce rate from impatient visitors.
CDN at BeBranded
We configure a CDN, most often Cloudflare, on every website project we ship, alongside proper caching rules, so a site loads fast for visitors regardless of where they are located.