What is CDN (Content Delivery Network)?
The best example of CDN operation is YouTube. It is estimated that 500 hours of video are uploaded onto the platform every minute. This is an unimaginable amount of movies, but any user from anywhere in the world can easily watch the recording in high definition. Why? YouTube works effectively and efficiently thanks to the global CDN network, which distributes recordings and redirects user traffic to servers closest to the device used by the Internet user. This gives everyone the best user experience.
In simple terms, A CDN is a service that allows us to serve static content (images, PDF, videos, CSS, JS, etc.) from servers that are geographically closest to the visitor entering the web.
What does this influence? Well, the distance in kilometers (although it is not exactly like that) influences the latency: the greater the distance, the greater the latency. The more latency or PING there is between the visitor and the web server, the slower the responses will be. It can also be said that from a certain “level”, the downloading of requests will also slow down and there could even be packet loss in the connection.
What should be clear to us is that to serve the web as quickly as possible in ALL possible situations, we must be very careful with high latencies.
What a CDN does is cache and save these static contents of the types that we previously select and save them for a certain number of hours or days on the service's servers, in a data center in a certain area of the world.
Later, through an anycast DNS service, when the visitor makes a request to the web, the service checks which is the POP (point of presence) or data center that is closest to the visitor. In this way, those files are served from the nearest servers.
How do content delivery networks work?
The main task of CDN is to improve website performance and speed up website loading times. It works by transferring the content you post to distributed servers that cache the content and serve users geographically. When someone enters a site that is part of the CDN, the network redirects the request from the site's server to the CDN server closest to the user. CDN networks enable active communication between servers in order to download and cache content that has not yet been distributed throughout the network.
The very way the CDN works is practically unnoticeable to the user. All content transfers and redirects are done on the server-side. The effects of distributed networks, however, have a very positive effect on the user experience on the visited website. Content such as photos and videos is delivered without delay and of better quality, and subpages or opened windows load much faster.
The only clear sign of a CDN working is the automatic change of the website address. For example, Your website has several language versions or can be located in many domains (.pl, .com, .de, .uk). By entering "website name" based on location, the user will either see the site in the appropriate language or will be automatically redirected to a site in another domain.
Is a CDN service very noticeable?
Well, YES and NO, that is, it depends a lot on the case and there is no clear general rule to decide whether or not to implement a CDN.
But we must also distinguish between a pure CDN by a reverse proxy that performs optimizations in the code. CDN can perform certain optimizations in the CSS and JS, so improvements may occur that do not come from the implementation of the CDN service, but from the optimization.
But we are going to try to make clear some points or circumstances in which a CDN can help us:
If you have a website with content in English, with a mixed percentage of traffic from the US and other regions of the world.
If you have an online store that sells throughout Europe.
If you have a website, of any type, that is multi-language in the same domain.
When the geographical distances are wider, the difference in loading speed is much more noticeable. Recall that it is noticeable because this does not affect only 1 specific request for an image, but it affects requests from the entire web, but especially the heaviest ones.
In some cases, you can even notice the results a bit more due to the proxy cache it implements.
Another of the key points of CDNs is that they are capable of serving static, in many cases, faster than web hosting servers. After all, they are prepared for that and use Nginx or high-performance web servers to serve the content.
Also, CDN servers are much better equipped to handle high volumes of traffic than normal hosting servers. They are for that, after all.
Is it worth using CDN?
The benefits of using distributed networks depend on the size of the page, the amount of content on it, and the users' requirements. However, they will all benefit from the four primary benefits associated with a CDN.
Loading time and page quality
If your page loads too slowly, users will stop visiting it. Thanks to the distribution of servers and choosing the right connection, data distribution takes less time. Your pages and content load quickly and the user will immediately achieve the purpose of his visit. In the case of multimedia content, the speed of data transfer is also related to their quality, which has a positive effect on the user experience.
Availability and redundancy
There are many factors that can disrupt a website's performance - a sudden rush of visits or hardware failures are some of the most common reasons for not accessing a website. CDN networks will offset the effects of such situations. The content is hosted on many devices to which the network may redirect excessive traffic. In the event of a server failure, the CDN automatically designates the closest one to ensure uninterrupted access to the site.
The CDN network also improves the security of your pages and sites. By improving security certificates and distracting servers, you will secure your website, including against DDoS attack, the operation of which is to seize all available service resources to block access to the website.
Positioning the website in Google (SEO)
Internet search engine algorithms take into account many features and attributes of pages. Page loading speed, graphics indexing, security, e.g. with an SSL certificate - these elements affect the positioning of your website. By using CDN, you will help your website achieve a higher position in Google search results.
How to implement a CDN
The implementation of a CDN on a website depends entirely on the type of CDN. As we have said, there are two types: Traditional CDN and Reverse Proxy CDN.
In a reverse proxy CDN, you simply have to follow the process that the service tells us and that normally (always) goes through changing the DNS in our domain for the DNS provided by them.
But… What about traditional CDNs? Well, in traditional CDNs we must configure a CNAME pointed to the hostname provided by the CDN and which will act as a bridge to cache the files using pull.
The process may vary depending on the domain provider that we use since not all have the same interface. We must configure a CNAME in our DNS server that points to the hostname provided by the CDN in question that we are configured.
After configuring the CNAME part, we must proceed to configure CNAME or CNAMEs in the CMS in question. We are going to tell you what you have to do in the case of WordPress. The intention is that the CMS, automatically, substitutes the paths of the files or requests that we want to serve from the CDN.
Set up a CDN in WordPress
There are different ways to implement and configure a CDN in WordPress and, depending on the cache plugin that we use, we will use one solution or another. If we use WP Rocket, W3 Total Cache, or LiteSpeed Cache, these plugins include a CDN configuration tab that allows us to add these CNAMEs easily. In case you want to use another plugin that is not the cache one to configure a CDN in WordPress. There are not many options and not many that are free:
Perfmatters: It is premium and has more features; Among them, the possibility of configuring Conditional Load from a cool interface.
Domain Sharding: It is not exactly to implement a CDN but it is free, although it takes a long time without updating.
CDN Enabler: A plugin developed by KeyCDN but used to implement any CDN in WordPress.
Once we do the configuration, we must check that nothing has been broken and that the requests are made to the CDN. For this, we can use Pingdom Tools.
Set up a CDN
Some of the few CMS that have the CDN configuration integrated natively. The thing is since it's not called that, people usually don't know what the specific option is for.
In "Media Servers" is where you must place the CNAMEs that you just created in your DNS. It will automatically replace the upload URL of most static files with the new URLs that you upload from the CDN.
CDN for jQuery and other libraries
Another point is that there are certain CDN services for widely used libraries, such as jQuery or for the most used WordPress files and CMS. These CDNs usually serve both the normal and minified versions of the libraries, which is quite helpful for the website's WPO. They are usually a good complement to a normal CDN.
Google CDN for bookstores
Google also maintains a powerful CDN with Google Cloud, from where we can use certain libraries loaded from Google's servers. It has certain limitations and is more oriented to jQuery and its libraries.
How CDN is used on a WordPress website?
You’ve probably heard a lot about WordPress CDNs and their ability to speed up web pages, among other uses. And I am not surprised, since the speed of navigation on a website is, without a doubt, one of the most relevant factors to improve the user experience, while your users navigate through the pages of your website. Nowadays, a page that takes several seconds to display on the screen will make the user lose patience and abandon it, to find what they are looking for elsewhere.
After all, everything on the Internet is just a few mouse clicks away, so why wait when you can go elsewhere with little effort? In turn, the user experience influences the SEO of a website, since Google penalizes pages that take too long to load, precisely because of their negative effect on this factor.
This, until now, was reason enough to get on our feet and start optimizing images, installing a cache plugin, using low-resource plugins, etc.
Until we discover that CDNs exist!
Unlike other optimizations made on resources or components installed on the webserver or in WordPress, with a CDN external servers intervene, which interact with the webserver to accelerate the download of a web page and, consequently, the browsing speed.
What CDN does on a WordPress Website?
A CDN is, very briefly, a set of servers distributed throughout the planet and connected to each other through the Internet.
But, I believe that the best way to understand what a CDN is and how it works is by first knowing the process that is followed, from when a user enters an address in their browser until the corresponding web page appears on the screen.
Although there are no significant differences with other content managers, in order to simplify the description of this process, we are going to assume from now on that we access the web page of a site in WordPress. The procedure would be as follows:
The user enters the address in his browser.
The browser identifies the server corresponding to that address and requests the corresponding web page.
The server receives this request and WordPress generates an HTML file, from the information stored in its databases.
Said server sends this HTML file to the browser that made the request.
When the browser receives the HTML file, it reads and interprets its content.
During this interpretation, references (web addresses) to various resources, such as style files or images, may appear that are part of the content or structure of the web page.
For each of these references, the browser requests that resource from the same server.
The server serves each of these requests, locating the corresponding resource on your hard drive and sending it to the browser.
As the browser receives these resources, it generates and displays the web page to the user.
The use of this type of tool frees the hosting server from this last task so that it will only have to take care of the browser's requests. For its part, the CDN will be in charge of dealing with referrals to resources.
How does a CDN work?
If we analyze in detail the process, we will observe that a large part of the work done by the hosting server is not, paradoxically, dedicated to the most important task: generating and delivering the HTML page to the browser that requests it.
Instead, the hosting server spends a lot of processing time simply locating and delivering resource files to the browser.
Among these resources, the most frequent are images, which tend to take up considerably more space and, consequently, consume more bandwidth than the HTML page itself, no matter how optimized they are.
With this resource, the hosting server can focus its work on what is important: attending to user requests, generating the requested HTML files, and delivering them back.
Until now, we have only stopped to see the external effect of using it, but surely you are beginning to glimpse some of the advantages it can bring us. But, before looking at what it is for in detail, let's stop a bit to know how CDN's work and thus better understand all its possibilities.
Schematically, the principle of the operation of a CDN is based on the following 3 points:
Having an extensive network of servers, connected through the Internet, scattered throughout the entire land geography.
Storing locally on these servers a copy of all the static resource files that we have on our hosting server.
Interfering and attending to the requests for these resource files when a browser requests them to generate and display the web page to the user.
Let's see each point in more detail below...
Having a Network of Servers
Although until now we have referred to the CDN in a singular way, as if it were a single element, in reality, it is a set of servers, distributed throughout the planet and connected to each other through the Internet.
Thanks to this provision, when a browser requests a resource, it is served by the server closest to its own geographic location, greatly reducing the time for sending and receiving data. The internal management and operation of this network of servers are completely transparent both for the owner of the website that uses the CDN and for the users who browse through its pages. For both, it has the external appearance of a single server that delivers the resource files over the Internet.
Storing resources locally
It makes sense, since if the CDN (we do not care which of its servers) is going to deliver, for example, an image to a browser, it must have that image file on its own hard drive. If I had to request it from the hosting server, we would no longer have all the benefits that it could provide us. It would even negatively affect performance since two requests would have to be made for the same file.
The way in which these files arrive is stored and distributed among its servers, which may vary depending on the configuration of the service and is also transparent to us, without our having to intervene at all.
By default, most CDNs make a local copy of all resource files when they are installed and activated for the first time. Likewise, the CDN itself is in charge of checking that its local copy is updated with any change in the original file on the hosting server.
Interfering and Responding to Requests for Resources
So far, we have a network of servers and, distributed in them, a copy of all our resource files. However, the references (web addresses) to these resources from the HTML code of the web pages remain on our hosting server.
This means that when the browser reads and interprets these web addresses in the HTML code, it will continue to request them from the hosting server, not from the servers. Therefore, for the browser to download these files from the CDN, those web addresses will have to be changed so that they point to the CDN servers instead of the hosting server.
Here we can get a little scared: do we have to change the web addresses of ALL our images?
In principle, yes, but the providers of this type of tool provide tools (such as a CDN plugin for WordPress ), to do it for us automatically, so we should not worry about that either.
Operating modes of a CDN
Providers for WordPress can choose between two alternatives when it comes to interfering and responding to requests for resources:
The first we have already described previously: a CDN WordPress plugin, provided by its provider, that modifies the web addresses in the HTML code of the web pages so that they point to the respective copies of the resource files on the servers.
Once this plugin is installed and configured, the process of changing web addresses is automatic and transparent, both for the website owner and for the users who browse it, who do not have to know where the resources are actually hosted.
For its part, in the second modality, the web addresses on the pages do not change, but the servers serve those addresses directly as if they were the original hosting server. In this case, the WordPress CDN server works as a proxy, placing itself between the browser and the hosting server.
When the server can supply the requested resource, because it has a local copy, it delivers it at that time. If it cannot supply it, either because it is not stored on your hard drive or because it is an outdated copy, it redirects the request to the hosting server for service.
With this mode, the hosting server will always be behind the CDN server, so you get an additional layer of security against possible external attacks, which must first pass through it.
In addition, it has the possibility of storing a static copy of the web pages, behaving as a cache server, especially useful when our content pages change infrequently.
The CDN server itself is responsible for periodically updating these static copies to ensure that users always have access to the most recent version of the pages.
What is a CDN WordPress for?
Now that we know what this term is and how it works, let's see what services a CDN provides us in WordPress and how we can take advantage of them to improve the response time of our server and, consequently, the browsing speed of our users:
1. Storage and delivery of static resource files
Fundamentally images and CSS files. This is the main characteristic of servers and almost their reason for being.
As mentioned above, by having a local copy of the static resources, the hosting server is freed from having to send them to the browser when a user accesses one of its web pages, freeing it up to do other tasks.
2. Cache of dynamic resources
Dynamic resources are those that a content manager generates each time the website is visited.
For example, in WordPress, web pages are generated every time a user accesses it. When the website has many visits, this process is repeated continuously, which affects the performance of the hosting server.
To avoid this, you can configure a CDN for WordPress, which stores a static copy of these dynamic pages and acts as a cache, when several users browse the same pages. He himself is in charge of keeping his local static copies updated with the hosting server.
At this point, it should be noted that not all WordPress CDNs offer this service and that, in most cases, it is usually a paid service.
3. Faster response for users from other countries
Our hosting server is one, or a small set of servers if the website is large, located in a single geographic location.
This server attends the requests made by users from anywhere in the world.
The further away from that user is, the more transit time the data needs to transfer from the browser to the server and vice versa.
With this resource, this problem disappears, since they have their servers spread out on all continents.
When a user accesses our website, they will be served by the CDN server that is closest to their physical location, significantly reducing the transit time and, consequently, the downloading and browsing time of the website.
4. Optimization of the use of resources of the hosting server
We already mentioned above what the complete process of generating and downloading a web page looked like, in which much of the capacity of the hosting server, such as processing time and bandwidth, was dedicated to the attention and download of static resource files.
By outsourcing this download, the server can dedicate a greater percentage of its power to what is really important: the attention to the users and the generation of the web pages they visit. In this way, you will be able to serve a greater number of users and serve more web pages without negatively affecting download and browsing time.
5. Protection against hacker attacks
Especially Denial of Service (DoS or DDoS) attacks, which consists of making a high number of simultaneous accesses to the server, in order to saturate it and not be able to meet the requests of legitimate users.
CDN servers have mechanisms to detect when this type of attack occurs and to counteract them, avoiding or limiting the effect it may have on the normal operation of the hosting server.
However, a WordPress CDN should not be used as the main protection tool against this type of attack, since the hosting server is still accessible through the Internet and hackers can find ways to access it directly, by skirting the servers.
Therefore, to prevent these direct attacks, you should always also have quality web hosting, which has security measures against these attacks.
Can I only use a CDN for websites in WordPress?
WordPress is the most used content manager for practically any type and size of the web, from blogs with only articles to true eCommerce platforms with everything you need to make purchases online. This hegemony means that service providers of this type dedicate more efforts to solutions adapted for WordPress web, if only because they have a greater volume of clients that use this manager.
In addition, the community of WordPress CDN users is also considerably larger, making it easier and faster to find solutions to problems that other users have already had, solved, and shared with the community.
However, this does not mean that it cannot be used with other content managers. The CDN providers offer plugins, add- ons or modules to integrate their servers in key content managers of the market, not only CDN's for WordPress.
In those cases in which this type of provider does not provide a plugin for a content manager, you can go to their support service or the user community to ask if there is a viable alternative that is easy to implement.
On the other hand, even if a particular provider does not offer a solution or support for a specific content manager, there is such a wide range of providers on the market that, almost certainly, some of them offer a solution for this. manager.
How can I install a CDN for my WordPress website?
Installing a CDN on a WordPress website does not present many difficulties, thanks to the fact that the providers provide plugins that do much of the work, along with the configuration of the service, to register the website.
Although each provider of this type of resource has its respective particularities when installing and configuring the plugin and the service itself, the main difference is given by the operating mode:
Redirection of the URL's of the resource files
For this modality, the integration of service of this type requires these 2 general steps (the details may vary slightly between providers):
Register on the CDN platform, through the provider's website and activate the website that the CDN will use. Although the nomenclature may vary between providers, they are often referred to as a “zone”. To this zone, it associates a URL, which we must write down.
Install the plugin for the CDN, which will take care of redirecting all the resource files. To do this, we must configure the zone URL that we noted in the previous point.
CDN Server as Proxy
Integrating a service of this nature that works as a proxy also requires two general steps:
Register on the CDN platform, through the provider's website, and activate the website. In doing so, it provides the name servers for the website's domain.
Change the name servers at the provider to point to the CDN name servers. From that moment, any access to the website will always and exclusively be done through the servers.
In this case, it is not essential to install the CDN plugin for WordPress, since the previous changes are sufficient for the operation of the resource. Although it is advisable, to be able to configure some areas without having to enter the provider's website.
Change of name servers
This change depends on the domain provider that we have contracted. Let's see the steps that, in general, we must follow with any provider:
Access our account on the domain name provider's website.
Among the configuration options, locate the option that shows the servers provided by the provider.
The provider always supplies two DNS servers. We must modify them to enter instead of the two name servers
Once the modification is made, it may take up to 24-48 hours for the change to spread throughout the network. It is not possible to accelerate it, so we can only wait.
There may be several reasons that lead us to consider its use, such as optimizing organic positioning, adding an additional layer of security against hackers to the website, or better use of the resources of the hosting server.
Despite the technical complexity behind its operation, providers have provided easy-to-install and configure mechanisms and tools for the most popular content managers, including WordPress CDNs.
Although many providers provide free plans, most have a time limit, after which it requires the contracting of a paid plan, depending on the level of traffic and visits to the website. These can work in two ways: rewriting the URLs of the static resource files of the website or behaving as a proxy server.