What Is a CDN? Content Delivery Networks Explained Simply
A CDN keeps copies of your site's files on servers around the world so pages load faster. How caching works, why updates can lag, and what to ask your AI.
Mythex Team · · 5 min read
A CDN (content delivery network) is a network of servers spread across many cities that keep copies of your website's files — images, scripts, stylesheets, sometimes whole pages. When someone visits your site, they're served from a location near them instead of from one faraway server. That makes pages load faster, takes load off your own server, and helps the site cope with traffic spikes.
Why CDNs matter when you build with AI
You may never set up a CDN yourself — many hosting platforms put one in front of your site automatically. But you'll feel its effects:
- Speed. Faster-loading pages keep visitors around and are one of the things search engines consider. See how to make your website faster.
- "Why is my change not showing?" After you publish an update, a cached copy of the old version can hang around for a short while. Knowing why saves a lot of confusion.
- Privacy and correctness. If a CDN caches the wrong thing — a page with one user's details — the next visitor can see it. Knowing what should and shouldn't be cached helps you ask the right questions.
An everyday analogy
Imagine a bakery that sells its bread nationwide from one shop. Every customer, however far away, has to wait for delivery from that single shop — and on a busy day the queue is enormous.
A CDN is like stocking the same bread in local corner shops across the country. Customers pick it up nearby, quickly, and the main bakery only has to restock the corner shops now and then. The catch: when the bakery changes its recipe, the corner shops keep selling the old loaves until they're told to replace them or the old stock expires.
How a CDN works
- Your origin. Your site lives on your main server or hosting platform — called the origin.
- Edge locations. The CDN runs servers in many places, called edge locations or points of presence.
- Routing. When a visitor requests your site, DNS or network routing sends them to a nearby edge. See how domains and DNS work.
- Cache hit. If that edge already has a fresh copy of the file, it sends it immediately.
- Cache miss. If not, the edge fetches it from your origin, sends it to the visitor, and keeps a copy for the next person.
- Expiry. Each copy is kept for a set time, controlled by cache headers your server sends, or until it's purged.
A worked example: a portfolio site with photos
A photographer's portfolio has a home page, a gallery with 60 large images, and a contact form. The origin is in Europe. A visitor in Singapore opens the gallery.
- Without a CDN: every image travels from Europe. Each request takes a round trip across the world, so the gallery fills in slowly.
- With a CDN: the first visitor near Singapore causes the edge there to fetch and store the images. Every later visitor in that region gets them from nearby, much faster.
Now the photographer replaces the home page's hero photo and republishes. Here's what decides whether visitors see it:
/index.html → short cache time, checked often
/assets/index-3f9a2c.js → cached for a long time
/assets/hero-8b41d0.jpg → cached for a long time
Modern build tools, including Vite, give files hashed names like hero-8b41d0.jpg. When a file changes, its name changes, so the page asks for a brand-new file that no cache has seen before. The HTML page itself is cached only briefly, so it soon points visitors to the new files. That's the standard way to get both long caching and fresh updates.
The contact form is different. Its submissions go to the server every time; they should never be cached.
What to cache and what not to
| Usually cache (long) | Usually cache briefly | Don't cache in a shared CDN |
|---|---|---|
| Images, fonts, videos | HTML pages of a public site | Logged-in pages, dashboards |
| JavaScript and CSS with hashed names | Public API data that changes occasionally | Anything with personal data |
| Downloadable files that rarely change | Form submissions, payments, any POST request |
Key terms
| Term | Meaning |
|---|---|
| Origin | Your main server or host, where the real files live. |
| Edge / PoP | A CDN location that serves visitors nearby. |
| Cache hit / miss | The edge had the file / had to fetch it from the origin. |
| TTL | Time to live — how long a cached copy is kept. |
| Cache-Control header | The instruction your server sends saying whether and how long something may be cached. |
| Purge / invalidate | Telling the CDN to throw away cached copies now. |
| Cache busting | Changing a file's name or URL when it changes, so caches fetch the new one. |
| Latency | The delay caused by distance and network hops. |
For caching more generally — in browsers, servers and databases — see what caching is.
Common misconceptions
- "A CDN makes everything faster." It speeds up delivering files. A slow database query or a slow AI call on your server is still slow.
- "A CDN replaces hosting." It sits in front of your hosting. You still need an origin.
- "If I updated the site, everyone sees it instantly." Old copies can linger briefly in the CDN and in browsers. Hard-refresh to check, and use hashed file names.
- "Caching is always safe." Caching a personalised page in a shared cache is a real privacy risk. Private responses should be marked as not cacheable.
- "CDNs are only for big companies." Many hosts include one for small sites at no extra effort.
What to ask your AI builder
- "Is there a CDN in front of this site? Which files does it cache, and for how long?"
- "Make sure built JavaScript, CSS and images have hashed file names and long cache times, and HTML has a short one."
- "Never cache logged-in pages or API responses with personal data in a shared cache."
- "Compress and resize images so the gallery loads quickly."
- "I published an update but still see the old version — is it the browser cache or the CDN?"
CDNs and Mythex
When you publish on Mythex, static front ends are deployed as static sites, and the docs note that CDN caches can lag briefly after an update: if you still see an old version after republishing, hard-refresh the public URL. There's nothing to configure for that. If you connect a custom domain whose DNS is on Cloudflare, the docs ask you to set the record to "DNS only" rather than proxied, so Mythex can issue HTTPS correctly. See how to publish and custom domains in the docs, and our guide to web hosting.
Questions
What is a CDN in simple terms?
A CDN (content delivery network) is a network of servers in many locations that keep copies of your website's files. Visitors are served from a location near them instead of from your main server, so pages load faster and your server does less work.
Why do I still see the old version of my site after updating it?
Usually because a copy of the old file is cached — in the CDN, in your browser, or both. A hard refresh fixes the browser side; CDN copies expire on their own or can be purged. Build tools avoid most of this by giving changed files new names.
Do I need a CDN for a small website?
You often have one without choosing it, because many hosting platforms put a CDN in front of sites automatically. If yours doesn't and your visitors are spread across countries, adding one is usually worthwhile.
Can a CDN cache my app's data and logged-in pages?
It can cache anything it's allowed to, which is why it must be set up carefully. Public files like images, scripts and styles are ideal. Personal or logged-in content should normally not be cached in a shared CDN, or one user could see another's data.