How to set up a CDN for a WordPress site: Cloudflare tutorial

The dynamic effect of the current website is getting better and better, and the content is getting richer and richer. If your website is aimed at the whole world and not just at home, the loading speed of your website may be slow when users from other parts of the world visit your website. This may cause users to give up visiting your website. And the average size of the current web page is 2MB, almost twice the data in 2015.

Moreover, the loading speed of the website will directly affect the SEO effect and user experience of the website.

The use of CDN (Content Delivery Network) is one of the best ways to shorten the page load time. But there are many ways to do this, but Cloudflare is a special one. The most important thing is that we can use Cloudflare for free.

What is CDN?

The full name of CDN is Content Delivery Network, which is a way to quickly deliver content to end users. If the data center of the website you visit is far away, the data loading speed will be very slow.

CDN means that every time a user visits a website, there is no need to call the server where the website is located every time. The CDN will copy the webpage, and then when the user visits the website, the content will be directly distributed to the terminal visitor from the server closest to the user.

Introduction to Cloudflare CDN

Cloudflare is a content distribution network that acts as an agent between the website and website visitors. This system allows users to receive cached static content from the nearest server. The shorter the physical distance, the faster the website will load.

And the power of Cloudflare is that it has one of the largest server networks in the world. Therefore, no matter where the visitors of your website are above, Cloudflare can help visitors quickly access the website. Moreover, this is definitely helpful for the optimization of website ranking, because speed is after all an important factor in search ranking.

Compared with traditional CDNs, Cloudflare has introduced many useful features:

  • Mitigating DDos attacks;
  • Analyze all the behavior of calling the website;
  • Install SSL certificate for free;
  • Gateway between protocols

How CDN works

To understand the working principle of CDN, we must first figure out why CDN is needed. Web hosting hosts often have only one physical location (that is, there is only one location in reality). If the site’s visitors are geographically close to the site’s hosting host, the content delivery speed will be very fast; but if the site’s visitors are geographically far away from the site’s hosting host’s physical location, the speed at which these users can open the site It will be slower.

Here is an example. If the server data center of a website is located in London, then users located in the United Kingdom, France, and Germany will open the website much faster than users located in Japan.

In order to avoid such delays in the content transmission process, the content distribution network (CDN) will copy the web pages of the website and save them on servers in all corners of the world. In order to ensure that the content is quickly distributed to each visiting user, CDN uses PoP points scattered in all corners of the world. These points include multiple servers, and these servers can ensure that the content is quickly distributed to nearby users. CDN can distribute dynamic content and static content at the same time, and these content usually include media files, HTML, JavaScript and CSS files.

According to the above example, if a Japanese user wants to visit a website whose web server data center is located in London, the Japanese user can directly access the CDN server located in Japan, so that they can also open the website at a very fast speed.

Setting up a CDN for a WordPress site: Cloudflare tutorial

Installing CloudFlare on WordPress is the most straightforward way. You can follow the tutorial below.

Step 1: Create a Cloudflare account

Visit the Cloudflare website and click the Sign up button to start creating an account. Next, we can fill in the email address in the order of the usual registration account, set the password, and finally click Create Account to create the account.

Step 2: Add the domain name to Cloudflare

1. First, we select the +Add Site button under the “You currently don’t have any websites” notification on the Cloudflare control panel.


3. In the next step, we need to choose a package. For personal stations, it is recommended that everyone choose the Free (free) version. Otherwise, you need to choose the Pro version or the Business (enterprise) version. Then we click Confirm Plan to confirm the package of our choice.

Step 3: Check the NDS record of the website domain name in Cloudflare

After entering the website domain name in the previous step, your own WordPress website will be added to Cloudflare, and the user will see the website DNS details. In this step, we can enable or disable Cloudflare for specific subdomains. Next we can switch the Proxy Status to orange.

Cloudflare domain

It is recommended that you enable naked domain names and www subdomains. In this way, Cloudflare can be used in both the www and non-www website versions at the same time. Next, we click the Continue button to proceed to the next step.

Notice! It is not recommended that you enable cPanel, email, FTP, or other options that may cause various DNS problems.

Step 4: Point the website domain name to the Cloudflare domain name server

  • After enabling Cloudflare for the website domain name and subdomain name, we will see Cloudflare’s nameserver (domain name server) on the next page. Next, we need to use Cloudflare to replace the old name server.
  • 1. Create a new tab page on the browser, and then visit the cPanel where the website domain name is located. If you are using Hostinger, the most cost-effective web hosting host, you can directly see the namesevers option in the Domains option.
  • 2. Then we select the first option with the word Default. After clicking, we see the next page asking us to replace the existing nameserver with the nameserver on Cloudflare. We should log in to the personal account of the virtual host where our website is located, enter cPanel, find the nameserver option, and then replace the DNS with the content on Cloudflare (usually in the form of Finally, we click the button with the word Update to save the settings.
  • 3. Return to the Cloudflare page and click the Done, Check nameservers button on the page to save the settings. Then click Done at the bottom of the newly appeared page to complete the operation. Next, the spread of NDS on a global scale is approximately 72 hours. Once the Nameserver (domain name server) is changed, users can receive a confirmation email from Cloudflare. Of course, users can also log on to the Cloudflare website to check the status. During this period, all pages on the website will be free from errors or inaccessibility.

Step 5: Install Cloudflare on the WordPress website and set it up

To complete the whole process, we also need to install the Cloudflare plugin on the back end of the WordPress website. This plugin has many functions for managing CDN, such as:

  • One-click optimization of WordPress;
  • Network application firewall;
  • Automatically clear website cache;
  • Statistical data;
  • Cloudflare’s built-in modification settings;

Next we install the plugin.

  1. Log in to the back end of the WordPress website and follow the order of plug-in → install plug-in. Then search for the Cloudflare plugin and install it.
  2. Visit the Settings section of the website and select Cloudflare.
  3. Select the API Key option under the Log in field.

4. Cloudflare account information will appear on the new page that pops up. Then we select the API Tokens tab, and then select the View button behind the Global API option.

Cloudflare account information
  • Next, enter the password of Cloudflare, and then copy the API Key.
  • Return to the plug-in settings page, paste the secret key just below the login field, and then click the Save API Credentials button.

After logging into the Cloudflare plugin, we will see several options.

  • Apply Recommended Cloudflare Settings for WordPress-Click the Apply blue button at the back to enable Cloudflare recommended settings, which can be used for basic security performance protection and optimized performance settings for the website.
  • Purge Cache-This option refers to purge all cache files. After the WordPress version is upgraded, or after changing the design of the website, we can enable this option. This option can clear all cache files on the website.
  • Automatic Platform Optimization-refers to the automatic optimization platform, but this project requires us to pay for Cloudflare services. This option can improve the overall performance of your WordPress site.

Summary of common problems related to CDN

The content of the above section is the main practical exercise part in this article. However, there are still many issues related to CDN, which are listed here for your reference.

CDN is an essential element for an international website, especially for users who have independent websites for cross-border e-commerce. After all, CDN can greatly enhance the user experience and improve the overall performance of the website. CDN services are widely used in the field of WordPress website building, and these users generally hope to improve the user experience of the website. And companies that use CDN services are generally large digital companies, entertainment companies, medical and health companies, education and marketing companies… However, there is a special situation that needs our attention. If the customers or readers targeted by your website business are local, and most of the customers belong to your area. Then using CDN may be counterproductive. This is because in this case, the CDN may add unnecessary servers. After all, the physical server is in the local area and there is no need for additional content distribution tools.

WordPress is a content management system that consumes a lot of static data and dynamic data at the same time. Generally speaking, WordPress sites are built on the basis of templates or themes, and certain functions are implemented through plugins. The header, footer, banner image, and menu of a web page generally do not change frequently, and these contents can be cached through a CDN.

Save bandwidth Because the CDN does not grab the content from the web server, but caches the content itself and provides a copy of the content. This can save users a lot of bandwidth. This may not sound great, but it can save a lot of money for high-traffic sites.

Safety The security of the website is the biggest problem faced by the WordPress website, but this problem can be solved by CND. CDN strengthens the security of the website because it can identify some of the more well-known security threats, such as DDoS attacks and spam using robots and certain scripts.

Handling huge traffic Websites with huge traffic can use CDN servers to balance the network. Even if the web server receives many new call requests, the cached content can be displayed to the end user.

Speed ​​up Because CDN can retrieve cached content from servers all over the world at any time, it reduces the loading time of web pages and improves the loading speed of web pages. This also helps to improve the user experience and also reduces the exit rate of website visitors.

SEO ranking higher In previous articles, we mentioned many times that the loading speed of a website is a very important indicator in the Google ranking factor. CDN can greatly improve the performance of the website, so the use of CDN can improve the search ranking of the website.

Site stability CDN can ensure that the website can still run when encountering server problems. Because if one of the servers in the CDN network has a problem, the servers in other corners of the world can still operate normally.

Other CDN providers

Many companies have also launched CDN services, and different CDNs also include different packages. We recommend that you must conduct research on suppliers before choosing CDN services. The following CDN vendors have a good reputation in the market.

In the past, integrating a CDN with a WordPress site was a test of people, because there were many places to set it up. With more and more modern plug-ins, the field of website construction is also changing more and more. Nowadays, adding CDN to WordPress is just a few simple steps.

Concluding remarks

CDN is the content distribution network, which can help improve the loading speed of the website. After all, ensuring the loading speed of the website is as important as the security of the website. No matter which country the visitors of the website are in, it must be ensured that they can access the website quickly. But using CDN is the simplest and most economical way.

Cloudflare is recommended among so many products because its CDN service is very reliable, and its security and performance are guaranteed. The most important thing is that we can use Cloudflare for free to optimize our WordPress site. The whole setup process is generally divided into the following steps:

  • Create a Cloudflare account;
  • Add the website domain name to Cloudflare;
  • Check the DNS records of the website domain name on Cloudflare, and then enable Cloudflare for both www and non-www domains;
  • Point the domain name to Cloudflare’s nameserver;
  • Install Cloudflare plug-in and perform simple settings;

Finally, I hope this article is helpful to everyone.

6 thoughts on “How to set up a CDN for a WordPress site: Cloudflare tutorial

  1. Heya i am for the primary time here. I found this board and I in finding It really useful & it helped me out a lot. I hope to give one thing back and aid others like you aided me.|

  2. Wonderful website you have here but I was curious if you knew of any user discussion forums that cover the same topics talked about in this article? I’d really like to be a part of online community where I can get opinions from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Bless you!|

Leave a Reply

Your email address will not be published. Required fields are marked *