If you've worked on web performance for any amount of time, you've probably heard the advice:
“Put it behind a CDN.”
But what does a CDN actually do between the browser and your server?
The simplest way I think about it is this:
A CDN, or Content Delivery Network, is a distributed network of edge servers that delivers content from locations closer to users instead of sending every request back to one origin server.
That shorter path can reduce latency, speed up content delivery, reduce load on the origin, and make an application more resilient when traffic increases.
But the interesting part is what happens after a user hits your URL.
A request without a CDN
Imagine your application is hosted on an origin server in the United States.
A user in Singapore opens your website.
Without a CDN, requests for HTML, JavaScript, CSS, images, downloads, or other resources may have to travel all the way to your origin infrastructure and back.
Conceptually:
User in Singapore
↓
Internet
↓
Origin server in the US
↓
Internet
↓
User
That physical and network distance matters.
More distance generally means more network hops and more round trips, which can translate into additional latency.
Now put a CDN in between.
User
↓
Nearby CDN edge server
↓
Origin server (only when needed)
The CDN becomes a delivery layer between users and your origin.
So how does a CDN decide where requests go?
CDNs operate distributed edge servers across multiple geographic locations.
When a request comes in, technologies such as DNS-based routing, Anycast, and global traffic management can help direct that request toward an appropriate edge location.
Then the edge checks whether it can serve the content itself.
This is where caching becomes important.
Cache hit vs. cache miss
Two terms explain a large part of basic CDN behavior.
Cache hit
A cache hit means the requested resource is already stored on the edge server.
For example:
GET /images/product.png
If that image is already cached at a nearby edge location, the CDN can send it directly to the user.
The origin doesn't need to handle that request.
Cache miss
A cache miss means the requested content isn't currently available in that edge cache.
The CDN requests the resource from the origin, returns it to the user, and—depending on your cache rules—may store a copy for future requests.
So the flow becomes:
First request:
User → Edge → Origin → Edge → User
Later request:
User → Edge → User
This is one of the main reasons CDNs can reduce origin traffic as well as latency.
What controls how long something stays cached?
One important setting is TTL, or Time to Live.
TTL determines how long a cached resource can remain at the edge before it expires.
Assets that rarely change—such as logos, versioned JavaScript bundles, CSS, fonts, or software files—can often use longer cache durations.
Frequently changing resources may need shorter TTLs.
And if something needs to disappear from cache immediately, CDNs typically provide a cache purge mechanism.
This sounds simple, but cache policy can have a huge impact on CDN performance.
A CDN isn't just “cache everything forever.”
The real goal is deciding:
- what can be cached;
- where it should be cached;
- how long it should stay cached;
- and when it needs to be refreshed.
What about dynamic content?
This is where the idea that “CDNs are just caches” starts to break down.
Not everything can be cached.
API responses, authenticated pages, personalized content, shopping carts, and other dynamic requests may need to reach the origin.
A modern CDN can still help.
Even when a response isn't served from cache, CDN infrastructure can optimize the network path through techniques such as persistent connections, TCP/TLS optimization, dynamic acceleration, and newer protocols such as HTTP/2, HTTP/3, and QUIC.
So there are really two related ideas:
Caching reduces how often the origin is needed.
Network acceleration makes requests faster when the origin is needed.
Does a CDN replace web hosting?
No.
This is a distinction that sometimes gets lost.
Web hosting stores and runs your website or application. A CDN sits between users and that origin infrastructure to improve how content is delivered.
You still need an origin.
Think of it roughly like this:
| Web Hosting | CDN | |
|---|---|---|
| Main job | Host the application/content | Deliver and accelerate content |
| Location | Origin infrastructure | Distributed edge locations |
| Handles | Original application and files | Cached and accelerated requests |
| Goal | Run the site | Get content to users efficiently |
A CDN complements your hosting architecture rather than replacing it.
Do you actually need a CDN?
Not every side project needs an enterprise CDN setup.
But I'd start seriously considering one when:
- users are distributed across multiple countries or regions;
- performance varies significantly by geography;
- your application serves lots of images, video, JavaScript, downloads, or other large assets;
- your origin is handling a high volume of repeat requests;
- traffic spikes are becoming difficult to manage;
- availability and DDoS protection matter to the application.
The more geographically distributed your audience becomes, the more useful the edge model tends to become.
A CDN is also part of your reliability and security architecture
Performance gets most of the attention, but CDNs can do more than make pages load faster.
Because traffic passes through the CDN before reaching the origin, that network layer can also help with traffic distribution, origin protection, DDoS mitigation, web application security, and handling sudden spikes.
That makes the CDN an important infrastructure decision—not just a frontend optimization.
The short version
If I had to summarize CDN architecture in a few lines:
A CDN puts distributed edge infrastructure between users and your origin.
It can:
- route users toward an appropriate edge location;
- serve cached content without contacting the origin;
- retrieve and cache content when there's a cache miss;
- accelerate dynamic traffic that still needs the origin;
- reduce origin load;
- improve performance, scalability, reliability, and security.
Once you see the request flow, “use a CDN” stops feeling like a magic performance trick.
It's really a question of moving content and network processing closer to the people requesting it.
If you want a deeper breakdown of CDN caching, edge servers, common use cases, and how to evaluate a CDN provider, I found this more comprehensive guide useful:
Quick FAQ
What does CDN stand for?
CDN stands for Content Delivery Network.
What is a CDN in simple terms?
It's a distributed network of servers that helps deliver web content from locations closer to users.
Does a CDN host my website?
Not usually. Your hosting infrastructure remains the origin; the CDN works in front of it.
Can a CDN accelerate APIs?
Yes. Even when API responses aren't cached, CDNs can improve delivery through optimized routing and connection acceleration.
Is CDN caching the same as browser caching?
No. Browser caching stores content on an individual user's device, while CDN caching stores content at shared edge servers that can serve many users.
Top comments (0)