Ever wondered: what is a CDN? And what is a CDN used for? In this knowledge article, I shed a bit of light on this technology that is used a lot on the internet.
What is a CDN?
CDN is an abbreviation for Content Delivery Network and it does exactly what its name says: it delivers content over a network of servers.
When you host a website, it is usually placed on a single server, which is basically a computer connected to the internet. For every visitor that visits your website, some requests to this server are made.
These requests typically include the webpage itself, but also files such as images, stylesheets and scripts which are responsible for the functionalities and layout of a website. Upon a request for such a given file, the server will respond to this request, serving the file if it exists.
A CDN does basically the same. However, it does not consist of a single server but a worldwide network of so-called edge servers, which are also called points of presence, abbreviated as PoPs.
The difference is that a CDN will serve the file from a point of presence (PoP) that is close to a visitor requesting this file. And this will usually make the site load faster because its speed is now less dependent on which location a visitor is coming from.
Outside the core functionality, a CDN often has additional functionalities such as a firewall that can block attacks at your origin server.
How does a CDN work?
The below points give a simplified representation of how a CDN work:
- When a visitor requests an asset from a website, this request will be routed to the most optimal Point of Presence in the CDN. Usually, this is a server that is located geographically close to a visitor.
- The CDN checks if this asset (such as a webpage, file, image and so forth) is already on the given Point of Presence.
- If it is, it will directly serve this asset from the given PoP. Since this PoP is geographically close to the user, the file, image or thing will be served quickly.
- If it isn’t, the CDN will make a request to the origin server for the given asset. The origin server will respond with the asset and it will be served from the CDN upon subsequent requests. Subsequent visitors will also get this asset from the CDN.
What is a CDN used for?
A CDN can be used for various reasons, including:
- Speeding up a website, making it load fast from any location in the world
- Reducing the traffic and bandwidth to the origin server, and thereby reducing costs
- Hiding the origin server IP to the public to increase safety
- Improving the security of a (WordPress) website by blocking attacks on the CDN level
- Optimizing the delivery of assets (images, styles, scripts and more)
A CDN can also cache (serve) a complete site, as long as it is static. Dynamic sites, such as webshops or interactive forums are harder to cache on a CDN.
Some CDN Providers
There are many providers that offer CDN services. Even better (or worse, in case of an outage…), half of the internet depends on these CDN providers. Here are a couple of providers that are well known:
- Microsoft Azure CDN
- Amazon Cloudfront
- Google Cloud CDN
- QUIC.cloud (and more: how to set up WordPress with LiteSpeed and the QUIC.cloud CDN).
CDNs and WordPress
Many CDNs do work well together with WordPress, and some such as QUIC.cloud are even specially geared towards WordPress.
Since Cloudflare is free to start with, this is one of the most popular options used in combination with WordPress. Cloudflare works great with the Super Page Cache for Cloudflare plugin and the official Cloudflare WordPress plugin.
Many caching plugins also integrate with a CDN, and a couple of providers also provide their own custom plugin (such as the BunnyCDN plugin)