What Is a CDN? Why Your Site Loads Fast (or Doesn't) Far From Home
A CDN keeps copies of your site's files on servers around the world, so a visitor in Sydney doesn't wait for a server in Virginia. What a CDN does, what it can and can't speed up, how caching fits in, and the stale-content surprise that confuses beginners.
Your app feels fast when you test it. Then a friend on the other side of the world says it takes forever to load. Nothing is wrong with your code — the problem is distance. Data travels fast, but not instantly, and every round trip between a visitor and a far-away server adds delay.
A CDN (content delivery network) solves this.
What a CDN does
A CDN is a network of servers spread around the world — often in hundreds of cities. It keeps copies of your site's files close to your visitors.
Without a CDN, every visitor fetches everything from your one server. If it's in Virginia, a visitor in Sydney waits for each file to cross the Pacific and back.
With a CDN, the Sydney visitor gets files from a CDN server in Sydney. The first time a file is requested there, the CDN fetches it from your server and keeps a copy (that's caching). Every later visitor nearby gets that copy almost instantly.
The server a CDN fetches from is called your origin. The CDN's servers around the world are called edge locations.
What a CDN is good at
CDNs shine with static files — things that are the same for every visitor:
- Images, videos, and fonts
- CSS and JavaScript files
- Fully static pages (like a landing page or blog post)
These can be cached for a long time and served from the edge. For most sites, that's the majority of what gets downloaded, so a CDN makes a big difference.
What a CDN can't simply cache
Personal, changing content — a logged-in user's dashboard, their orders, their messages — is different for every person and changes constantly. It shouldn't be cached and shared (you really don't want one user seeing another's cached dashboard). Those requests pass through the CDN to your server.
So a CDN speeds up the "shell" and the static parts; your server and database still determine how fast personal data loads. Putting your server in the same region as your database, and near most of your users, still matters.
Other things CDNs do
Many CDNs also:
- Handle HTTPS — providing and renewing certificates.
- Absorb traffic spikes — a sudden rush of visitors hits the CDN, not your server.
- Block attacks — filtering out floods of junk traffic (DDoS protection) and some malicious requests.
- Compress and optimise files and images automatically.
Do you already have one?
Quite possibly. Many hosts include a CDN automatically — especially static hosts and frontend platforms. Some people add one in front of their server, often through services like Cloudflare, by pointing their domain's DNS through it.
If you're not sure, ask your host, or check your site's response headers in the browser's Network tab — CDNs usually add headers that mention them.
The stale-content surprise
Here's the thing that confuses beginners. You update your site, deploy, open it — and see the old version. Or you see the new version, but a friend sees the old one.
That's caching doing its job a bit too well: a copy of the old file is still stored — in the CDN, or in the visitor's browser.
How it's usually handled:
- Modern build tools give files unique names when their content changes (like
app.3f9a2c.js). A new deploy means new file names, so there's nothing stale to serve. This is why you rarely hit this with frameworks. - HTML pages are usually cached briefly or not at all, so they pick up the new file names quickly.
- CDNs let you purge the cache — clear stored copies — when something needs to update right away.
When you suspect caching: try a hard refresh (Ctrl+Shift+R or Cmd+Shift+R) or a private browser window. If the new version appears there, it's a cache — not a failed deploy.
Cache headers, briefly
Your server tells browsers and CDNs how long to keep a file using a Cache-Control header:
Cache-Control: public, max-age=31536000, immutable— keep this for a year; it will never change (perfect for files with unique names).Cache-Control: no-store— never cache this (right for private data).
Frameworks set sensible defaults. If you're hand-configuring caching, the golden rule is: never let a CDN cache a page that contains one user's private data.
The summary
- A CDN stores copies of your files on servers worldwide, close to visitors.
- Great for images, scripts, styles, and static pages; personal data still comes from your server.
- Many hosts include one already.
- Seeing an old version after a deploy? Probably a cache — try a hard refresh.
- Never cache private pages.
EasySpawn serves your app over HTTPS on your own domain with certificates handled automatically, and runs its database alongside it — so the personal-data part of your app stays fast too. See how it works or join the waitlist.
Related: What Is Web Hosting? · SEO Basics for Your App · Why Is My Website Slow? · HTTP Caching Headers
Keep reading
What Is Serverless? (There Are Still Servers)
Serverless means you write functions and the platform runs them on demand — no servers to manage, pay per use. What serverless really is, how it differs from an always-on server, cold starts, timeouts, and the database connection problem, and when it's the wrong fit.
Why Is My Website Slow? A Beginner's Guide to Finding Out
Slow sites lose visitors. How to measure speed properly, what Core Web Vitals mean, and the usual culprits in AI-built apps — huge images, too much JavaScript, slow database queries, waterfalls of API calls, and a server far from your users — with a fix for each.