One of the most interesting data about the people accessing your website is the country from which they reach you: how many nationalities can you identify?
And how many miles are they virtually traveling to read your content?
If your site is speaking to a broad international base, like WP Rocket’s, Google Analytics will undoubtedly show you country-pins scattered all around the world. There’s also the possibility that your readers are coming from one continent only: be it America, Europe, Asia, Oceania or Africa, they still have to cross very long distances to reach your origin server!
Every time a website aims to reach a wide international audience, their distance from the origin server is one of the critical factors of web performance.
So, if your server is in New York, but your readers are from San Francisco, or New Delhi, or Melbourne, how can you decrease the distance and allow all of them to benefit from your content at a similar speed?
In this article, we’re going to answer these questions, and explore the magic world of CDNs: a bridge that makes users closer to the websites they’re visiting, no matter where they are in the globe!
What Is a Content Delivery Network (CDN)?
The acronym CDN stands for Content Delivery Network: a CDN establishes a globally distributed network of edge servers between your website’s origin server and your visitors’ location.
Every HTTP request made by your users will be served from the nearest location possible, no matter where they’re geographically located.
How Does a CDN Work?
Let’s say the server hosting your website content (the origin server) is located in Madrid, but you receive many visits from people in Buenos Aires.
Every time one of your Argentinian users requests a page, all the assets contained in it have to travel from Buenos Aires to Madrid. Then the server has to send the assets back to the user in Buenos Aires. Quite a ride, isn’t it?
Contrary to the image above, this is not a ”direct flight” for your static content: during their journey from Spain to Argentina, they also have to travel through a series of routers along the way.
Each router has to process the request.
So every time an Argentinian visitor wants to access your website, two factors are affecting the amount of time (latency) needed for the request to be finalized:
- The total distance from Buenos Aires to Madrid
- The time it takes for each router on the way to process the request
The same thing happens when the origin server receives the request, and respond to the users, sending them back the content they asked to receive.
This round trip is measured in milliseconds and is called RTT (round trip time).
The primary goal of the CDN is to reduce latency and RTT.
Since the CDN is made by a globally distributed network of servers, every time your Argentinian visitors ask for your content, they won’t receive it from Spain.
The edge servers composing the CDN distributed network already have a cached version of the content of your website: whenever a user requests it, they can provide it quickly and securely.
In this way, round trip time is reduced, because the CDN may have different edge servers in South America, which are way closer than Madrid!
Take the image below as a reference:
On the left, all end-users are receiving content from the same server: the website requested by the user will be accessible only after every HTTP request is transmitted from the central location.
On the right, the same content is now delivered through different edge servers, linked to the origin one. Distances are shorter, meaning that loading time is optimized and end-users will be able to access the website much faster than before.
If you think that, on average, 80% of a website is made of static resources, you’ll get a better view of how a CDN could be beneficial for your site.
Which Is the Difference Between ”Pull” and ”Push” CDNs?
Most CDN services offer two different techniques to distribute static files to the edge servers:
- Through a pull zone
- Through a push zone
What Is a Pull Zone?
A “pull” zone (or “pull CDN”) is the technique that ”pulls” the static assets from your site, meaning that it will automatically import the files from the site to the CDN cache.
What Is a Push Zone?
A “push” zone (or “push CDN”) does not import any files automatically, but your site has to upload (push) them to the CDN. Once the files are pushed, the zone will be synchronized with the edge servers of the network.
We can think of push zone as a sort of repository to store content.
A push zone is the ideal solution if you’re serving big resources, such as large file archives, software updates, or any other file larger than 10MB. It can also be useful if you serve files that are not keen to change, like PDF documents, image galleries, etc.
Why Do the URLs of Static Files Change When the CDN Is Active?
Without a CDN, the URL path of your static files would be similar to:
But when you enable the CDN, they change and become something like:
where the first level domain cdnzonename-cdn.com is the CNAME provided by your CDN service (so it may vary belonging to the CDN you’re using, and it can usually be customized).
This happens because the static files are not coming from your origin server anymore: a third-party server is loading them, and this is the proof that the CDN network is now taking care of the delivery of your static assets.
Should You Use a CDN or Not?
If your website is intended to receive a lot of visits from locations far from your server, adopting a CDN is a fundamental step to implement in your web performance optimization strategy.
So, yes, you should use it.
What Are the Benefits of Using a CDN for a WordPress Site?
We already introduced some of the benefits that come with the adoption of a CDN service: applying a second layer of caching and reducing latency and RTT above all.
But three other factors make a CDN very profitable for your web optimization strategy. Let’s see them in detail:
1. CDNs Reduce Time to First Byte (TTFB)
Time to First Byte indicates the response time of a server.
It measures the amount of time needed by a server to load the HTML of a website so that the client can start rendering the page.
Simply speaking, it is the time your end-users have to wait before the page they requested starts displaying on their browsers.
Network latency is one of the elements that contribute to increasing Time to First Byte (along with other factors such as server configuration, server performance and DNS response time).
As we saw, when a CDN is enabled, static content will be cached by the edge server, reducing latency.
As a logical consequence, then, CDNs can contribute to decreasing Time to First Byte.
For more info about the techniques you can use to reduce TTFB, read our guide How to Reduce Time to First Byte and Load Your WordPress Site Faster.
2. CDNs Reduce Bandwidth Costs
Bandwidth is the amount of data transferred and downloaded from your website.
Hosting providers offer you a predetermined bandwidth that is included in your plan.
CDNs can decrease bandwidth costs because they reduce the burden on your hosting system: since your static content is cached through the CDN, your origin server won’t have to transfer those data to your end-users.
The final effect is that CDNs reduce the traffic passing through your origin server, and avoid the additional cost of bandwidth charges from your hosting.
3. CDNs Add a Security Layer to Your Site
According to the last NexusGuard report, during the first half of 2018 the increase in the size of DDoS attacks was quite scary: around 500% more than last year!
Distributed denial-of-service (DDoS) attacks are malicious attempts to overwhelm the capacity of the target server by flooding it with multiple simultaneous external requests. These attacks are like a massive traffic jam collapsing a highway, where the targeted server is the congested road which ends up being unavailable.
Because of its position on the edge of your network, a CDN acts as a protection against this type of attacks and other security threats for your origin server. This happens because the saturation provoked by the attack is processed on different machines, and it won’t reach the hosting server which remains up and available.
This is valid also for any other situation where traffic spikes could make your website suffer: the increased content availability is a plus that your users will appreciate.
So, Is a CDN Beneficial Also for SEO?
If you think that Google loves fast and secure websites, we can indeed confirm that enabling a CDN on your site is also beneficial for SEO.
When the CDN is working on the backend of your site, your content loads faster and remains available even during high loads of traffic: Google notices these details and consider them as a factor to improve your ranking!
How to Choose the Best CDN for Your Needs?
Now that you know what a CDN is and why you need one, it’s time to decide which type of CDN you should use.
There are several powerful CDN options on the market, so don’t worry if you feel a bit overwhelmed at first, it’s a normal feeling!
When choosing a CDN service, there are four factors to take into consideration:
- The predominant location of your visitors
- Your bandwidth requirements
- The size of your website
- Your budget
Considering these four elements is essential to pick the CDN that will best serve your needs and your audience.
Let’s see which are the most popular CDN services and how they differ:
Cloudflare markets itself as a CDN, even if the most accurate description for its services would be a reverse proxy.
Cloudflare’s network is powered by 155 data centers scattered around the world, including several centers in China.
They cache your static content and use an Anycast network, where the incoming request can be shared through different locations and redirected to the closest router of the network. Furthermore, they offer a lot of interesting features such as load balancing, minification, and Rocket Loader among others.
Concerning pricing, Cloudflare is one of the most popular CDN options: they offer a free plan (ideal for personal sites and blogs), a Pro Plan for $20/month and a Business Plan for $200/month.
Amazon Cloudfront – AWS
Amazon CloudFront is a CDN with a global network of 160 centers spread through 66 cities and 29 countries.
This CDN works as a push zone, meaning that you can use it to deliver all of your site content, including dynamic assets. It also provides an API thanks to which you can customize its behavior, configure multiple origin servers and maintain your CloudFront distributions.
As for pricing, charges are based on actual usage of the service; but they also offer a free version named AWS Free Tier which includes 50GB data transfer out, 2,000,000 HTTP and HTTPS requests each month for one year.
Struggling to choose between Cloudflare vs CloudFront? Read our guide Cloudflare vs Cloudfront, and we’ll help you choose the best CDN for your WordPress site.
Imperva (formerly Incapsula) CDN network is composed of 44 data centers in Europe, North America, Australia, India, and South-East Asia.
They are famous for their entreprise-target security since they offer a number of security features such as web application firewall (WAF) and DDoS mitigation.
They also provide load balancing and optimization features such as content minification and dynamic file compression.
KeyCDN is a small Content Delivery Network with 34 data centers focusing on high-performance and speed.
They offer several interesting features like geolocation routing, customized TCP stack, and Anycast network. You can also customize its use and create both Pull and Push Zones.
Their pricing includes unlimited HTTP and HTTPS requests and a pay-as-you-go structure starting at $0.04/GB for Europe and North America, $0.12/GB for Asia and $0.16/GB for Australia.
StackPath (formerly MaxCDN)
StackPath is a security-focused service which acquired MaxCDN in 2016.
MaxCDN was already pretty popular in the market for its reliable network; since the acquisition, the service could profit from StackPath’s various security features like advanced DDoS mitigation, access control and content protection among others.
They provide direct platform control through the EdgeRules technology, which allows you to monitor how your content behaves on every edge server.
At WP Rocket, we chose StackPath as the backbone of our custom CDN service, RocketCDN.
RocketCDN is our premium optimized CDN with a dedicated CNAME. We directly integrated it into WP Rocket, thanks to the Stackpath API.
Why Should You Use RocketCDN?
When you buy RocketCDN, we will provide you with a personal CNAME ending with rocketcdn.me
As a WP Rocket customer, you can directly activate your CDN subscription from your dashboard: this means you don’t need to look for an external CDN provider.
As for the configuration, you don’t need to worry about it: WP Rocket handles it automatically to provide the best speed results.
See our quick video-tutorial about RocketCDN.
Akamai is probably the most used CDN service by large businesses and enterprises and one of the oldest in the market.
They are globally known for their robust infrastructure and speedy networks. They evolved over the years, and are not a simple CDN service anymore: they define themselves as ”a cloud-based platform that takes your sites and apps closer to your end users.”
They can rely on more than a hundred thousands servers in more than 1300 locations.
Their pricing structure follows a pay-as-you-grow model, but prices are available only under request.
CDN77 is very young compared to the other solutions described so far: they launched in 2012 and now have 32 data centers.
Despite the young age, they were the first CDN to provide HTTP/2 support (something that now almost every CDN includes) and Brotli compression. They also offer a wide range of features like software distribution, live streaming, video-on-demand, private CDN and a special service for continuous gaming delivery.
Their pricing structure is a pay-as-you-go starting at $0.049 for 1GB (charges vary belonging to the country), or monthly plans starting at $199 per month.
Google Cloud CDN
Google Cloud CDN service takes advantage of Google’s distributed Edge Points of Presence around the world.
It caches HTTP and HTTPS load balanced content, guarantees a low latency thanks to the Anycast network, purges cache instantly and it can be integrated with Google Stackdriver for receiving detailed logging of requests.
But the most important thing you should know about Google Cloud CDN is that it only works if you’re hosting your site on Google Cloud Platform (GCP). If you’re out of the GCP, you can’t use their CDN, because they don’t support external origins.
Google Cloud CDN prices depend on the usage you make of it, as described in their pricing sheet.
In this article you learned:
- What a CDN is
- How CDNs work
- How you can benefit from a CDN to improve the performance of your website
- Which are the most used CDN services in the market
Now it’s time to go ahead and learn about other important factors to accelerate your website’s speed:
- What Is the Difference Between a CDN and Domain Sharding?
- Cloudflare: Should You Use It or Not?
- Cloudflare VS Cloufront: How They Work, Plus Whici Is Best for You
- Memcached: Object Caching to Boost Your Web Performance
- Varnish: Purge HTTP, Options and Configuration
- Time to First Byte: How to Test, Interpret and Reduce It!