Content delivery networks are marketed mainly as a way to speed up your website, among other things. You’ll often see people recommending this as a sure-fire way to improve your website’s load times, but is a CDN always, always, always going to make your site faster? Nope. Not at all.
But maybe that’s not always such a bad thing, because there are other benefits to using a CDN and reasons that it may be worth keeping around, even if it’s not making your site faster.
Let’s put together a scenario here, an example of when a CDN might not be faster.
Let’s say you’re located in downtown Toronto, and so is the datacenter that’s hosting your website. Your visitor, too, is located in downtown Toronto. In order to make your site as fast as possible, you’re using a CDN.
This hypothetical CDN provider doesn’t have any servers in Toronto, let alone Canada. The nearest server is located in New York. These two major cities aren’t terribly far from one another on the global stage, but New York is obviously a lot further from Toronto than Toronto is…
So, this creates a lot of extra distance for that website data to travel, instead of staying right in Toronto. In this particular case, the visitor from Toronto will likely have a slower time loading your site than someone viewing your site from New York, where the nearest CDN node is located.
This might seem like a very specific example, but think about all of the different possible combinations of server, CDN, and city locations. The whole point of a CDN is to give you a wider andfaster reach, so as many visitors as possible are able to reach your site from a nearby server, but it just doesn’t always work out like that.
If you have an absolutely stellar web host and a premium plan (something above shared hosting at the bare minimum, preferably a VPS or dedicated server), it’s entirely possible that your hosting plan on its own could be faster before adding a CDN.
There are different factors at play here, like the servers' Time to First Byte (TTFB), like what types of content you’re delivering, whether it’s huge databases, images, videos, and/or other contributing factors. A CDN will often help with speed, but not necessarily. A CDN will often make the largest impact when it’s paired up with a cheaper hosting plan and a poorly optimized site, since both of those traits leave so much room for improvement.
When you browse the best CDN offerings out there, sometimes you'll see a free tier and think "hey, that's a great deal." It usually isn't. When something's free, you are the product. What's happening is the CDN companies are using your site and its traffic to catalog and check IP addresses with malicious behavior.
An example is Cloudflare's free tier. You think that's great until you notice a bunch of your traffic has to wait 5 seconds while Cloudflare "checks their IP address." Why is this happening? Because they're collecting data for DDOS protection usage for their paying clients. Those guys never see this message, and that's in thanks to you being a sucker.
How many of your website users never end up loading your site because they aren't willing to wait 5 seconds while their IP is analyzed against a database? Tons. How much money is that "free" tier actually costing you...
Even if a content delivery network isn’t faster for your specific use case, it still might be worth considering using it, because they aren’t just for speed. A CDN will usually speed up your site, but it does a lot more.
Security: A CDN can help protect your site against intrusions, brute-force log-in attempts, and DDoS attacks. The level of protection will depend on the settings and which CDN you’re using, some are better than others when it comes to this, but even a basic one will protect you better than nothing.
Resources: Using a CDN frees up resources and bandwidth from your server, and passes some of the work off. As the name implies, you’re able to use the content delivery network to help deliver your content to your visitors. Your server will appreciate a lighter load during normal hours, and if your site goes viral or suddenly gets a boost of traffic for any reason, you’ll have more leeway - you’ll be able to withstand more traffic before your site crashes.
Downtime: A CDN can store a cached version of your site if you’re ever having technical difficulties. When people visit your URL, instead of getting an error, they’ll see a cached version of the site instead.
Many times, a CDN will be faster than not using it. For all of the times when your server and your website’s visitors aren’t nearby one another, a CDN will very likely give your users a better experience.
Serving up a cached static version of your site takes less resources than something dynamic. When you’re trying to move around less data, it takes less of a toll on your hosting server, and ultimately allows you to serve more visitors, more quickly... Most of the time. Server-side caching can achieve this too though.
Even if it doesn’t drastically improve your performance, it could still very well be worthwhile for you to get a CDN. Just make sure you consider the three scenarios above.