What is a CDN and Why Should You Care?

What is a CDN?

CDN stands for Content Delivery Network. It's a group of servers spread across different locations around the world, all holding copies of your website.

When someone visits your site, the CDN serves it from the closest server to them instead of from one central location.

Think of it like a chain of coffee shops. Instead of everyone driving to one location across town, there's one near you that serves the exact same coffee.

Why Does This Matter?

Speed. The closer a server is to your visitor, the faster your site loads.

If your website is hosted on a single server in New York and someone visits from California, the data has to travel across the country. With a CDN, a copy of your site is already sitting on a server in California, so it loads much faster.

A few reasons this matters for your business:

  • People leave slow websites — If your site takes more than 3 seconds to load, about half your visitors will leave
  • Google ranks faster sites higher — Site speed is a real factor in search results
  • Mobile users expect speed — And mobile connections can be slower than desktop

How Does It Work?

  1. Your website files are uploaded to your hosting server (the "origin")
  2. The CDN makes copies of those files and stores them on servers around the world
  3. When someone visits your site, the CDN routes them to the nearest copy
  4. If the content has changed, the CDN grabs a fresh copy from the origin

You don't have to do anything differently. The CDN works behind the scenes.

CDNs Do More Than Speed Now

Modern CDNs have evolved way beyond just caching files. Today they can:

  • Run code at the edge — Small bits of your site's logic can run on CDN servers closest to the visitor, making dynamic features nearly as fast as static ones
  • Block attacks — CDNs like Cloudflare stop millions of attacks every day before they ever reach your server
  • Handle traffic spikes — If your business goes viral on social media, a CDN keeps your site from crashing
  • Optimize images automatically — Serving the right size and format for each visitor's device

This is sometimes called "edge computing" — it just means your site is smarter about where and how it delivers content.

Do You Need One?

For a small local business, a CDN is nice to have and easy to set up. Even if your visitors are mostly nearby, you still benefit from the speed, security, and reliability.

The good news: many modern hosting platforms include a CDN for free. Cloudflare, for example, offers a free CDN and security layer that works with any website. If you're hosting on platforms like Cloudflare Pages, Netlify, or Vercel, a CDN is built in from day one.

The Simple Version

A CDN = faster, safer website for your visitors, no matter where they are. Most modern hosting includes one. If yours doesn't, it's worth adding — and it's usually free.

Want to know if your site is using a CDN? Ask us and we'll check for you.

CDN Internals: Caching, Edge Functions, and Cloudflare's Network

A CDN does more than just "copy your site to more places." Let's dig into the mechanics of how it actually works.

Cache Headers: How Browsers and CDNs Know What to Store

When your browser requests a file (like an image or a CSS stylesheet), the server's response includes cache headers — instructions that say how long to keep that file before asking for a fresh copy.

The two big ones:

  • Cache-Control — The main header. It says things like max-age=86400 (cache this for 24 hours) or no-cache (always check with the server first). This tells both the browser and the CDN how to handle the file.
  • ETag — A unique fingerprint for a specific version of a file. If the file hasn't changed, the server can say "you already have the latest version, use your cached copy" instead of sending the whole file again. This saves bandwidth and speeds things up.

Getting these right matters. Too aggressive caching means visitors might see outdated content. Too little caching means your site loads slower because everything is re-downloaded on every visit.

Cache Invalidation and Purging

So what happens when you update your website? The CDN might still be serving the old version from its cache. You need to invalidate (or purge) the cached content.

There are a few approaches:

  • Purge everything — Clear the entire cache. Simple but aggressive. Everything gets re-fetched on the next request.
  • Purge by URL — Clear specific files that changed. More precise but requires knowing exactly what changed.
  • Cache busting — Add a version number or hash to file names (like styles.abc123.css). When the file changes, the name changes, so the CDN treats it as a completely new file. This is the most reliable method and what most modern build tools do automatically.

Cloudflare lets you purge cache through their dashboard, API, or even automatically when you deploy. It's one of those things you rarely need to think about once it's configured.

Edge Functions and Workers

A traditional CDN just serves static files — images, CSS, JavaScript. But modern CDNs like Cloudflare also let you run code at the edge. This is where Cloudflare Workers come in.

A Worker is a small program that runs on Cloudflare's network, in the data center closest to your visitor. Instead of just serving a cached file, it can:

  • Rewrite URLs or redirect requests
  • Add security headers
  • Process form data
  • Fetch data from APIs or databases
  • Personalize content based on the visitor's location

This is incredibly powerful. Your code runs in 300+ locations worldwide with no servers to manage. It's how this site handles server-side rendering — Astro generates pages on Cloudflare's edge, right next to the visitor.

How Cloudflare's Network Is Organized

Cloudflare doesn't use the traditional "origin + edge" CDN model where you have a main server and cache servers around the world. Instead, every one of their 300+ data centers is a full node — each one can handle any request, run Workers, cache content, and apply security rules.

This means there's no "cache miss penalty" where a request has to travel back to a single origin server. Every data center is a first-class citizen. The result is consistently fast response times no matter where your visitors are.

Curious about how your site's caching is configured? Reach out — we can review your cache strategy and make sure you're getting the best performance.

Last reviewed for accuracy: February 2026

Rate this article

Have questions? We're happy to help. Get in touch for a free consultation.