CDN (content delivery network)
Also called content delivery network.
A network of servers around the world that keeps copies of your files close to users, so pages and media load faster.
Last updated
What it is.
When a user requests an image, script or page, the CDN serves it from the nearest edge location. If the edge does not have it, it fetches it once from your origin server and caches it for the next user. Rules set how long each file is cached.
Most CDNs also protect the origin from traffic spikes and attacks, terminate HTTPS and can run small pieces of code at the edge, called an edge function.
Why it matters
Distance adds delay to every request. A CDN cuts load times for users far from your servers, lowers load on the origin and often reduces egress costs, since many requests never reach your cloud. For media-heavy products it is a large part of the hosting bill.
In a product build
We give static files hashed names so they can be cached for a long time, set short or no caching on personalised responses, and keep user data out of cache keys. Large uploads go to object storage with the CDN in front.
Common mistakes.
- 01
Caching personalised pages, so one user sees another's data.
- 02
No way to purge, so a bad file stays live for hours.
- 03
Forgetting to compress and resize images, which keeps the bandwidth bill high.
Related terms.
- Edge functionA small piece of server code that runs on a CDN's servers around the world, close to the user, instead of in one central region.
- Egress (data transfer out)Data that leaves a cloud provider's network, such as files sent to users, which many providers bill per gigabyte.
- Object storageA way of storing files as objects in buckets, each with an ID and metadata, reached over HTTP and built to scale to huge amounts of data cheaply.
- Load balancerA service that spreads incoming traffic across several servers, and stops sending traffic to any that fail their health checks.
- PWA (progressive web app)A web app built with standard web technology that can be installed on a device and work offline, giving an experience close to a native app.
Guides and pages
Browse the full glossary or read answers to common questions.