What is a CDN, and does your website actually need one?
A content delivery network (CDN) keeps copies of your static files — images, CSS, JavaScript, fonts — on servers around the world, so each visitor downloads them from somewhere nearby rather than from your single origin server.
**When a CDN helps a lot.** If your visitors are geographically spread out, a CDN cuts the distance each asset travels, which feels faster and reduces the load on your server. It also absorbs traffic spikes and can serve as a first line of defence against some attacks.
**When it does nothing.** If all your visitors are in one city and your server is in that city, a CDN adds hops with no benefit. If your pages are highly dynamic (logged-in dashboards, personalised content), a CDN cannot cache the parts that matter most.
**How to get the most from one.** Keep static assets on a domain or path that can be cached aggressively, give them long cache lifetimes (the CDN handles invalidation via versioned filenames), and make sure your origin sends correct cache headers. Most CDN pain comes from the origin telling the network not to cache things it should.
**Start simple.** Measure your current latency from a few locations. If most of your users are close to your origin, spend your effort on making the origin fast instead. If they are far away, a CDN is one of the highest-leverage changes available — and it is often free to start.