I was mid way through another post, entitled something like '5 easy ways to speed up your website' when I realised that I couldn't succinctly explain what a CDN (or content delivery network) is. I know what a CDN does and why having one for your website is important. And I can set you one up, no problem. But explain, without jargon, in a way which makes sense to everyone? Slightly more tricky.

Gatekeeping –intentional or not– sucks! Through this blog, I really want to help break down some of the technical barriers which stand between website owners and the wealth of information out there, which is often aimed at developers. So before I start handing out advice about speeding up your website, I'm going to break things down, which hopefully will give you a bit more of an insight into the why behind my recommendations.

For those of you who have stumbled across this page and just want the question answered, the short version is below. For any fellow nerds who want to know more, grab a coffee and read on.

TLDR; A CDN plucks out the main culprits for slowing down page load (HTML pages, CSS, images, Javascript) and stores a version of them in servers dotted around the world, so that wherever you are, you can download that part of the website super quickly from a server near you, speeding up the overall time taken to load a page.


An introduction to content delivery networks (CDN)

CDN stands for content delivery network. Website owners setup or signup for CDN services, with the main goal of speeding up their website. This is important for your user's experience, but also for SEO as website performance is a major ranking factor. Users drop off quickly when things are slow and laggy, so good load times are crucial for building trust and making conversions.

I will talk about CDNs a lot on this blog, as they can be applied to any site, no matter how you built it and they are great for speeding things up when you don't have control over every aspect of your website and so can't help some things which are slowing it down ... Like a website performance plaster. That said, I would use a CDN on every bespoke built client website I use too and you won't find a household name social site / app or online service which isn't also relying on one.

You don't have to have a CDN in the same way you have to have a domain name or hosting, but it's always a good idea.

Yeah, but what IS it?

A geographically distributed network of servers, which work together to deliver your website's assets (HTML pages, images, CSS, javascript, font files etc) as quickly as possible. A CDN is not web hosting, so the assets are not uploaded to it, they stay on your web hosting but are cached by the CDN at the network edge.

The network edge sounds like some sort of futuristic place, that Elon Musk would drop a Tesla from, but it's actually just where the device you're using to look at a website, communicates with the internet. The network edge will be geographically and physically close to your device, unlike the cloud, which can be spread across data centres anywhere. Data centres are high tech buildings filled with computers.

Caching?

Think of caching as copying a file and storing it in a temporary location. A CDN caches your website files and stores them in convenient places you can access as you make your way across the internet. Imagine a squirrel, rather than having to make the long arduous journey to a park miles away to get food (eg. a web host that has data centres in California), it makes sense to store –cache!– nuts along the way, in convenient places.

This is what a CDN does with your website's assets. My web host has data centres in London, which is great for me in Cardiff as data doesn't have too far to travel. But that data still has to travel from the data centre to my device and that can cause internet latency.

Internet Latency? Huh?

Latency is the delay taken between you doing something on a website, such as pressing a button, and the server responding. The difference between data travelling from Cardiff to London and say London to California will be minute, a figure given in milliseconds. However with latency, every millisecond counts.

Especially as there is a lot of back and forth between you and the server in order to complete any task. The time it takes for the user to do something, for the server to respond and for the user to see the results of that is called round trip time, or RTT. When testing your website's performance, you might see RTT benchmarked.

Data's journey across the internet

It's not a direct flight, the data needs to pass through networking equipment along the way and pass through several networks. This can all slow down the RTT and increase the latency.

Every asset your website uses, from images to JavaScript files, makes what is called a HTTP request. When looking at your website's performance, it's a good idea to try and reduce the number of these HTTP requests, as they all interrupt and slow down the loading of the page. You will see the number of HTTP requests mentioned when you test your website's performance using something like Google Lighthouse.

Each HTTP request presents an opportunity for latency, as it passes through different networks on its journey across the internet. Some HTTP requests are render blocking, which means they prevent the rest of the page from being loaded, so slow things down even more.

Enter CDNs

If we can reduce how far the data has to travel, we can cut down the latency and minimise the RTT. Less distance to travel, fewer networks to pass through and less opportunity for issues with networking equipment.

So instead of you trying to download your website assets from the datacenter, you get a cached version from the internet equivalent of down the road. Whilst your device is still communicating with the data centre, wherever that may be, you can get those HTTP requests sorted quicker, so your overall page load isn't being held up.

Resulting in happy users and search engines. Yay!

Ok, I want a CDN!

If you use a managed solution (something like SquareSpace or Shopify) then you will already have a CDN setup and working for you.

However if you use something self hosted like WordPress, you're going to have to source and setup a CDN yourself. I'll cover that in a future post, but in the meantime there are lots of plugins which make the process easier, like W3 Total Cache.


I hope that this post helps explain what a CDN is, how it works and why having one for your website is a good idea.