The Rabbit Hole

The Rabbit Hole

Share this post

The Rabbit Hole
The Rabbit Hole
What is a CDN and How Do They Work? — Content Delivery Networks Explained
Copy link
Facebook
Email
Notes
More
User's avatar
Discover more from The Rabbit Hole
On Youtube, I am the channel @LearnFastMakeThings. This is where I share more about the topics in my videos. Subscribe for a much deeper dive into things I learned while making the things I made. Be warned, you might end up in a Rabbit Hole!
Already have an account? Sign in

What is a CDN and How Do They Work? — Content Delivery Networks Explained

Content delivery networks or CDNs are, at their most basic level, multi-function services designed to deliver the content on your website…

Gary Morse's avatar
Gary Morse
Sep 24, 2022

Share this post

The Rabbit Hole
The Rabbit Hole
What is a CDN and How Do They Work? — Content Delivery Networks Explained
Copy link
Facebook
Email
Notes
More
Share

Content delivery networks or CDNs are, at their most basic level, multi-function services designed to deliver the content on your website to users fast. There are many CDNs out on the market these days. Some of them are offered as stand-alone services like Cloudflare, Fastly, or Akamai others are offered directly by the big cloud companies themselves like google CDN or AWS Cloudfront.

No matter which company you choose as a CDN provider, they all offer one service in common and that is the ability to deliver certain parts of your website’s content faster than if it were served from its origin where you host it.

Essentially, when your site loads in a browser, all kinds of other stuff like images, CSS files, javascript files, and any other static content is fetched behind the scenes. If you don’t have a CDN, all of this content needs to come from your server. This, as I’m sure you can imagine, can put a heavy strain on your server and take a long time to be delivered (especially if the files are large or they are geographically far away from the machine that’s making the request).

presentation 003

When you introduce a CDN into the mix, requests for these individual static files are instead requested from the CDN network. The first time these files are requested, the CDN fetches them from your server like a normal request and then delivers them to the requesting machine. But… the next time someone requests the same file, the CDN doesn’t request it from your server and instead delivers it from its caches.

The benefits of this are twofold. First off, your server now only has to serve these files occasionally since the CDN is serving them for you. Second, the CDN provider will distribute your file to many edge endpoints all around the world so the amount of time it takes to be delivered is dramatically shortened.

So that all sounds pretty cool, but how does that work from a technical standpoint?

There are a couple of different ways that CDNs are set up depending on which one you choose. Some CDNs work by giving you a completely different domain name specifically for delivering your static content. For example, if you had “myawesomesite.com”, you may set up static.myawesomesite.com. The static subdomain points to the CDN and then you instruct the CDN to fetch the content from your actual site and serve the content from its edge. Usually in this scenario when someone loads your site at myawesomesite.com, you would then change the URLs of all of the static content like images and CSS to point to the static subdomain. This allows your dynamic content to be served directly from your server while all of the additional assets are pulled from the CDN network.

presentation 005

The other way some CDNs work is by actually proxying your whole website, but only caching the things that are cachable. In this scenario, you would point myawsomesite.com to the CDN network and then the CDN provider would evaluate each request and determine if that request should receive a cached file or if it should be passed back to your origin machine to get content served from your server directly.

presentation 006

No matter which way your CDN provider operates, there are certain things to look out for before you just flip the switch and start enjoying the benefits. mainly, you need to make sure the CDN knows how long to cache a file and if it should be cached in the first place. Every CDN provider has slightly different ways to control their caching rules and most of them offer some sort of control panel for making custom rules. But most of them will also honor the cache headers served by your origin server. Now, caching headers is a completely different topic worthy of another article, but essentially you can specify how long a file should be cached by setting headers in the HTTP response. When a CDN sees these headers, they then know how long the file can be kept before fetching it again.

Finally, while every CDN is primarily a way to deliver content faster, some CDNs offer more robust features than that. For example, Cloudflare has expanded its offering of basic CDN into a full-blown application firewall that allows you to not only speed up your site but also protect it from surges in traffic and even block common exploits like SQL injection.

Ok cool, so CDNs sound great, but are they expensive?

Well, that all depends on what you are looking for. While many of the CDNs I have mentioned here have a cost and often charge based on the amount of data consumed, they aren’t necessarily expensive. For example, AWS Cloudfront charges by the volume of data processed. If you don’t have a lot of traffic, you don’t pay a lot. Pretty simple. But probably even better than that, Cloudflare has a free offering for websites that offers a subset of their total features. You may not get everything they offer, but you do get the basics of DDOS protection and content delivery from the edge which is what most basic sites need anyways. If your site grows, just add more features and cough up the cash.

Alright, I think I’ll leave it there. Until next time. Happy coding.


Subscribe to The Rabbit Hole

By Gary Morse · Launched a year ago
On Youtube, I am the channel @LearnFastMakeThings. This is where I share more about the topics in my videos. Subscribe for a much deeper dive into things I learned while making the things I made. Be warned, you might end up in a Rabbit Hole!

Share this post

The Rabbit Hole
The Rabbit Hole
What is a CDN and How Do They Work? — Content Delivery Networks Explained
Copy link
Facebook
Email
Notes
More
Share

Discussion about this post

User's avatar
Step-by-Step: Adding Shared Storage to a Kubernetes Cluster
Today I’m going to show you how to expand the capabilities of a Kubernetes cluster by adding shared storage
Mar 13, 2023 • 
Gary Morse

Share this post

The Rabbit Hole
The Rabbit Hole
Step-by-Step: Adding Shared Storage to a Kubernetes Cluster
Copy link
Facebook
Email
Notes
More
How To Turn Your Old Hardware Into A Kubernetes Cluster
Today I’m going to show you how to set up Kubernetes on an old computer that you may have sitting around.
Mar 12, 2023 • 
Gary Morse

Share this post

The Rabbit Hole
The Rabbit Hole
How To Turn Your Old Hardware Into A Kubernetes Cluster
Copy link
Facebook
Email
Notes
More
How to Download Files from Github: 4 Easy Methods
If you’re new to coding or just really like to find cool software on the web, you’ve probably come across GitHub
Mar 29, 2023 • 
Gary Morse

Share this post

The Rabbit Hole
The Rabbit Hole
How to Download Files from Github: 4 Easy Methods
Copy link
Facebook
Email
Notes
More

Ready for more?

© 2025 Ask Cloud Architech LLC
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More

Create your profile

User's avatar

Only paid subscribers can comment on this post

Already a paid subscriber? Sign in

Check your email

For your security, we need to re-authenticate you.

Click the link we sent to , or click here to sign in.