Video in progress
What is a CDN, and what content should be served through it?
A CDN is a network of servers spread around the world that serves content from the point closest to the user. Mostly static things: images, video, JS/CSS, fonts, downloadable files.
📖 Answer
If your server is in Frankfurt and the user is in Tashkent, every image request travels a long way. A CDN stores the image on an edge server near Tashkent, and later users get it from there.
There are two benefits: speed for the user, and traffic load taken off your server. On a big video platform, most of the traffic goes through the CDN.
Good fits for a CDN:
- versioned static files (
main.8c1d.css) — with a long TTL; - images, video segments;
- public pages that are the same for everyone.
Bad fits:
- responses with personal data (profile, cart, balance) — they could end up going to another user;
- fast-changing API responses.
In practice the most common mistake is a wrong Cache-Control on the CDN, so a logged-in user's page becomes visible to other people.
Sign up to mark studied questions and save your progress.