How to Set Up Cloudflare’s Free CDN for WordPress

In this post, we’ll explore what a CDN is, how it can reduce the loading time of our webpages, and specifically how the Cloudflare CDN can improve our website’s security. We’ll also provide a step-by-step guide on setting up the Cloudflare CDN with our WordPress website.

What Is a CDN?

A Content Delivery Network (CDN) is a system of distributed servers that deliver content to a user based on their geographic location.

Essentially, the CDN stores a cached version of content in multiple geographical locations, each known as a Point of Presence (PoP), with each PoP optimized to respond quickly to nearby requests.

For example, if a user in New York is trying to access a webpage whose servers are located in London, a CDN can provide a cached version of the site from a server closer to New York, such as one in Boston.

Without CDN: Animation showing website loading slowly without a CDN

By minimizing the physical distance that requests and responses need to travel, we can decrease latency and guarantee quicker loading times for the user.

With CDN: Animation showing website loading quickly with a CDN, with elements appearing almost instantly

What Is an Origin?

In CDNs, “origin” means the main server where content is stored. The CDN gets content from this server and then sends it to different nodes or edge servers. The origin is essentially the main source of truth.

A CDN will respond immediately to a request if it already has a valid copy of the requested resource. If it doesn’t, it retrieves it from the origin server. This method makes sure the request is handled correctly while updating the cache for future requests. Many CDNs will automatically fetch a fresh copy of a resource when it expires in the cache so that the next request doesn’t have to wait for retrieval from the origin server.

The CDN then stores a copy of this content on its edge servers nearest to the user making the request, reducing the distance the data needs to travel and improving the speed of content delivery.

Diagram illustrating content delivery directly from the origin server without a CDN

Why Cloudflare’s CDN?

Cloudflare’s industry-leading CDN provides more functionality than conventional CDNs and is perfect for those seeking to enhance their website’s performance while enhancing security.

Cloudflare has invested considerably in a global network of edge servers. This investment reduces the travel distance of data, significantly decreasing page loading times. As a result, websites using Cloudflare can respond to requests faster due to the presence of a nearby Cloudflare Point of Presence (PoP).

Besides offering exceptional traditional CDN services, Cloudflare’s CDN also provides enhanced security with Distributed Denial of Service (DDoS) protection. This effectively shields your website from harmful traffic and potential attacks. Have you ever tried to visit a site but received a page saying it’s verifying that you’re human before bringing you to the site? This was likely Cloudflare’s DDoS protection page.

Example of Cloudflare’s DDoS prevention page.

Setting up Cloudflare CDN is a simple process. It includes copying your existing domain records, switching your nameservers to Cloudflare, and configuring your origin. Cloudflare offers detailed guides and support, making the setup process manageable for users at any technical level.

Later in this article, we’ll show you how to set up Cloudflare CDN for a WordPress website.

Another key feature of Cloudflare is their Automatic Platform Optimization (APO) plugin. For a nominal fee, this service offers a specific plugin designed for WordPress websites. This aims to enhance site performance by optimizing different aspects of your site, ensuring more content is served from their edge servers. This results in a faster experience for your visitors and a greatly reduced Time To First Byte (TTFB).

Can Cloudflare CDN Improve My SEO?

Indeed it can!

Search engines favor websites that load quickly. Thus, using a CDN not only will enhance the user experience and boost conversion rates, it will help your website rank higher in search engine results.

While website load speed is important, it’s influenced by various factors and difficult to quantify. Time to First Byte (TTFB) is one such metric, which is the time taken from the visitor making the request to the time the browser receives the first byte of data. TTFB is another metric improved by Cloudflare’s vast content delivery network.

A lower TTFB means that your website users can start receiving data quickly, contributing to a better user experience, particularly for websites that rely heavily on dynamic content. By caching static assets on edge servers close to the user, Cloudflare CDN reduces the need for requests to travel back to the origin server, thereby decreasing TTFB. This means users start seeing your website content sooner, which can contribute to lower bounce rates, higher user engagement, and improved SEO rankings.

Time to First Byte (TTFB) is one metric, but it’s just one of many metrics that contribute to the overall performance, user experience and search ranking of a website. For example, search engines frown upon downtime and unavailability and will have a negative impact on SEO. If your website is frequently inaccessible, your site will see a decrease in search ranking.

Utilizing Cloudflare’s CDN significantly helps in this scenario. It not only offloads requests to the CDN but also delivers the cached version of your site to visitors, including search engines, during an incident. By offloading traffic to Cloudflare’s distributed network, you can effectively eliminate a single point of failure when loading your website while ensuring search engines never consider it as unavailable.

Cloudflare CDN also provides analytics, giving you insight into traffic patterns, threats, and performance of your website. This helps you understand your audience and make data-driven decisions to further enhance your website’s performance.

Can Cloudflare CDN Improve the Security of My Website?

Cloudflare CDN significantly enhances the security of your website by shielding your origin server from certain types of malicious attacks, most notably, Distributed Denial of Service (DDoS) attacks.

DDoS attacks typically involve flooding a server with massive amounts of traffic, aiming to overwhelm it and cause it to slow down or crash. This can lead to severe disruptions to a website’s functionality and availability. However, Cloudflare’s CDN mitigates this threat by intelligently spreading the traffic across its global network of servers. Essentially, when a DDoS attack is detected, the traffic is dispersed among different servers in the network, preventing any single server from getting overwhelmed.

Moreover, Cloudflare’s CDN can distinguish between legitimate traffic and DDoS traffic. It filters out harmful DDoS traffic while ensuring that legitimate users still have access to the website. This allows the website to operate normally while the attack is being managed.

If the CDN does not already have a cached version of the requested resource, it retrieves it from the origin server. This process is designed to handle DDoS attacks, as the CDN can absorb and filter out a significant portion of harmful traffic, preventing the origin server from becoming overwhelmed and crashing.

While Cloudflare’s CDN is highly effective at managing DDoS attacks, it’s not entirely foolproof. Some sophisticated attacks may still pose a threat. It should only be considered as part of your security strategy to ensure your website remains protected against various threats and potential vulnerabilities. Your origin server may be virtually invisible behind a CDN at times – but it’s not invincible.

Set Up Cloudflare for WordPress

1. Set Up Domain

Once you’re logged into Cloudflare, click Add site within the header. You will be taken to the first step of the process which is to enter your website’s domain name.

Screenshot of adding a site to Cloudflare in the WordPress Cloudflare plugin setup

2. Select a Plan

Cloudflare offers numerous plans, each with unique features.

For now, we will choose the Free plan.

Screenshot of selecting a plan in the WordPress Cloudflare plugin setup process.

3. Review DNS Records

Once you add your WordPress site, Cloudflare will automatically scan your domain and include any Domain Name System (DNS) records it identifies.

Think of DNS records like an internet phone book. However, rather than finding phone numbers, DNS connects website names to their online addresses. For instance, if your browser needs to locate the server hosting your website, it will refer to the DNS records to obtain the IP address of the host.

Cloudflare attempts to locate all existing DNS records. However, it might not find some of them. Therefore, we recommend cross-checking these records with your current configuration before proceeding.

Screenshot of reviewing DNS records in the WordPress Cloudflare plugin setup

4. Change Your Nameservers

Cloudflare will guide you to change your nameservers. Make sure to note both of the Cloudflare nameservers before proceeding to your domain name registrar.

Screenshot of changing nameservers in the WordPress Cloudflare plugin setup

While the exact steps may differ slightly based on your domain name registrar, they generally follow a similar pattern. Your registrar will provide specific instructions for updating your nameservers from their dashboard or control panel.

The goal is to replace your current nameservers with those provided by Cloudflare. Once this is done, you can return to Cloudflare and select Check nameservers now.

Screenshot of changing nameservers in the WordPress Cloudflare plugin setup, continued

Note: It may take up to 24 hours for the domain to propagate the new nameservers.

Configure Cloudflare CDN for WordPress

In the following section, we will provide a detailed guide on how to set up Cloudflare for your WordPress site. The Cloudflare WordPress plugin streamlines the integration of Cloudflare’s services with your WordPress site, ensuring optimal performance and simple management of your CDN settings.

Begin by retrieving your Cloudflare API key. To do this, visit your profile and select API Tokens from the left-hand sidebar. Then, click the View button next to your Global API Key.

You might be prompted to enter your password before you can view your key.

Screenshot of entering the Cloudflare Global API Key in the WordPress Cloudflare plugin settings

As stated in the modal window, treat this key with the same care as you would a password.

Now that we have the credentials we need, log in to your WordPress dashboard and navigate to the Plugins section. Click on Add New and search for “Cloudflare”. Install and activate the Cloudflare plugin for WordPress by Cloudflare, Inc.

Screenshot of installing the WordPress plugin in the Cloudflare setup process

After the plugin is installed and activated, you will need to sign in to connect your Cloudflare account.

Screenshot of signing into Cloudflare within the WordPress plugin interface

Click the here link under the Create Your Free Account button and enter the email address used when creating your account along with the API key.

Screenshot indicating completion of Cloudflare setup within the WordPress plugin

Cloudflare settings are adjusted to boost the website’s performance and security. These settings include a medium security level, standard caching, and automatic minification of JavaScript, CSS, and HTML files. The browser cache TTL (Time to live) is set for 4 hours, and Cloudflare ensures that the site remains accessible, serving cached versions if the origin server is unavailable.

Several other features such as IPv6 Compatibility, WebSockets, and IP Geolocation are activated for enhanced functionality and security with hotlink protection deactivated.

For the complete list of features that are enabled when using the one-click configuration, see the Cloudflare developers documentation.

Undoubtedly, one of the main benefits for installing and configuring the Cloudflare WordPress Plugin, is support for Automatic Cache Management. This feature ensures seamless and efficient caching of your WordPress site’s content, optimizing its performance without requiring manual intervention. You can explore more about Automatic Cache Management and its benefits here.

Cloudflare APO

Cloudflare’s Automatic Platform Optimization (APO) is an additional service that can further enhance your WordPress website’s performance. For a nominal fee of $5/month, this service offers a specific plugin designed for WordPress websites.

APO works by optimizing various aspects of your site, ensuring that more content is served from their edge servers, resulting in a faster experience for your visitors. This greatly reduces the Time To First Byte (TTFB), which means your users start receiving data more quickly.

Setting up APO is straightforward and can be done within your Cloudflare dashboard. Once configured, APO will automatically optimize your website’s delivery, without requiring any additional changes on your part.

It’s important to note that while APO can significantly improve your website’s performance, it should be used in conjunction with other best practices for site optimization, such as using a quality hosting provider, optimizing your images, and minimizing your use of heavy plugins.

For detailed instructions on setting up APO, please refer to this Cloudflare tutorial on YouTube.

Conclusion

In conclusion, a Content Delivery Network (CDN) like Cloudflare offers many benefits, from improved website loading speed and availability to enhanced security. Regardless of the size or type of your website, utilizing a CDN can significantly enhance the user experience, SEO rankings, and overall performance of your site. With its simple setup process and advanced features, Cloudflare makes it easy for every website to take full advantage of what a CDN can offer. We highly recommend considering the use of a CDN to ensure your site remains fast, reliable, and secure.

Avatar photo
Author

Andrew Cairns, Software Engineer Consultant

Andrew has decades of experience within the software industry. He has worked at small start-ups and large enterprise organizations in a variety of roles, including Staff Engineer and VP of Engineering. He is particularly passionate about Software Architecture and Domain Modeling.

Want your face and bio here? ☝

Write an article like this and get paid well. Check out our writers program

Start Your 7-Day Free Trial

Begin your SpinupWP journey today and spin up your first server within minutes.

Subscribe to get the latest news, updates and optimizations in performance and security.

You are already logged in

It looks like you are already logged in to SpinupWP.

Please log out of this account to continue.

Registration Successful

Thanks for registering for a new SpinupWP account.

Before getting started, could you verify your email address by clicking on the link we just emailed to you?

Start Your 7-Day Free Trial

No credit card required. All features included.

By signing up to SpinupWP, you agree to our Terms and Conditions.
For privacy related information, view our Privacy Policy.