How To Set Up CDN For Your WordPress Website

It’s considered a must-have as it enhances a site’s speed and performance, as well as avoids DDoS (Distributed Denial of Service) attacks. In short, having a CDN for your WordPress website is very useful.

In this article, we’ll cover the following questions: what is a CDN, why do you need a CDN for your WordPress website and finally, how do you set-up a CDN for your WordPress website.

What is a CDN?

CDN is short for Content Delivery Network, which can be described as a network of servers that delivers cached static content from websites to users based on the geographic location of the user. Pretty confusing, eh? Don’t worry – we’ll break it down in detail below.

Normally when a user comes to your WordPress website, they’re immediately redirected to your web host’s server (i.e HostGator). Your web host’s server is located at a central location (i.e Houston, TX). Every user on your website is accessing this one server in order to view your website. If you have a high volume of traffic at any given time, you can overload your server, leading to a slow loading time or even a server crash.

This is where a CDN comes in handy because it’s a network of servers – spread across the world! When you use a CDN, your static content (images, stylesheets, PDFs, JavaScripts, Flash, CSS files, etc.) is cached and stored on all of these servers. Now when a user visits your site (original server), the CDN technology redirects them to the closest server to their location. How cool is that?

For example, if your main server is hosted in Houston, TX, and someone from Durham, England accesses your site, they’ll be redirected to the closest server which may be in London. This limits the number of internet hops needed to transmit the static files to your end user.

Users’ proximity to your web server has a direct impact on load time. By deploying your content across multiple geographically dispersed servers you can make your pages load faster from the user’s perspective. This is one of the greatest advantages of having a CDN. In short, the closer the CDN server is to where your user is, the faster the user gets the content.

Why Do You Need a CDN for Your WordPress Website?

With the information provided above, you can already see that having a CDN can have a hugely positive impact on a website. Below are more detailed advantages that we’ve seen on the Artbees website just by using a CDN:

  • Speed – Once we started using a CDN on our WordPress website, the site got faster.
  • Crash Resistance – Thanks to article shares, we often received big waves of website traffic from social media. If it wasn’t for the proper CDN and caching setup, our site would crash frequently. CDN allows us to distribute the traffic load to multiple servers instead of having 100% of the traffic directed to our main server, thus making it less likely to crash.
  • Improved User Experience – Since using a CDN, we’ve noticed a decline in the bounce rate on our site. Furthermore, we’ve also seen an increase in page views and numbers of pages viewed by each user. So clearly a fast site means improved user experience.
  • Improvement in SEO – Google emphasizes that faster sites tend to rank higher in search engines. We noticed our site ranking improved once we did the optimization on our site.

How Do You Set-Up a CDN for Your WordPress Website?

In terms of CDN, there are lots of options out there. For the sake of this article, we’ll guide you in setting up a Free CDN for your WordPress website with the Cloudflare CDN service. You can also take a look at 10+ Free CDN services here if you want to do some research before choosing one.

What is ClouldFlare?

CloudFlare is a Web Application Firewall, a distributed proxy server, and a content delivery network (CDN). It optimizes your website by acting as a proxy between visitors and your server, which protects your website against DDoS attacks.

Cloudflare offers a free basic plan suitable for small websites and blogs. They also offer paid plans starting at $20 per month.

Note:

Before you implement CloudFlare to improve your website’s speed please make sure that it is not your web host that’s slowing you down. If you think that it might be your web host, perhaps you should first consider switching to a better WordPress hosting provider. If you’re going to use CloudFlare, then we recommend BlueHost. They’re one of the official CloudFlare partners and one of the official WordPress recommended hosting providers.

How to Setup CloudFlare for your WordPress Site?

Part 1: Create a Cloudflare account and add a website.

Signing up for Cloudflare is incredibly easy and takes less than 5 minutes.

  • Go to www.cloudflare.com and click the Sign Up button at the top of the page.
  • Create a Cloudflare account by typing your email address and password. Click Create Account to proceed.

(Pro Tip: We recommend using an email alias or distribution list. For example, cloudflare@company.com. Billing and service-related email notifications will be sent to this email address.)

  • Enter the domain for your website and then click Begin Scan. It’s not necessary to add “www” to the domain. For example, if your website is www.example.com, type example.com.

 

 

  • Next Cloudflare will scan your domain’s DNS records. This will take approximately 60 seconds to complete. Once the DNS scan has finished, click Continue.
  • A list of all the DNS records found will be displayed, including your subdomains. In this step, you can decide which subdomains you want to enable Cloudflare or bypass Cloudflare. Some records, like MX, never go through Cloudflare (no cloud).
  • If there are any additional records you’d like to add, you can add them here. After you’ve reviewed your DNS records, click Process and Continue.

 

 

  • Select a plan that fits your needs and then click Process and Continue.
  • On the final step, you’re given the Cloudflare nameservers for your domain. The Cloudflare nameservers are assigned to your domain and listed on this page. Please write down the Cloudflare nameservers. You can also find your Cloudflare nameservers in your Cloudflare dashboard under Overview.
  • If you’d like, you can choose the appropriate Performance and Security settings. By default, your Performance settings are set to CDN Only and your Security profile is set to Medium for your domain. You can change your settings at a later time.
  • Click Process and Continue.

 

 

  • Congratulations! You’ve successfully created your new Cloudflare account! But you’re not done yet! The final step is to update the nameservers for your domain with the Cloudflare nameservers provided in the previous step.
  • You should now proceed to the Crypto tab of your new Cloudflare account to verify that Cloudflare’s Universal SSL records have been provisioned for your domain. They should appear as two records in the Edge Certificates section: One for your root domain (example.com) and one wildcard subdomain record (*.example.com). Once you have verified that those are in place you are all set to serve SSL! If you do not see those records yet do not worry, they should be provisioned within 24 hours (please contact support@cloudflare.com if they are not). In the meantime, we recommend Pausing Cloudflare until they are provisioned.

Note: Please allow up to 72 hours for the nameserver information to propagate. You’ll receive a confirmation email from Cloudflare when the nameservers update is complete. Your site will not experience any downtime during this period.

Part 2: Using Cloudflare with WordPress

 

Preparing the Server

If you have control of your web server, here are some tips that’ll make your life easier. If you don’t have control of your web server feel free to skip this section.

On an Apache server, it’s a great idea to install the latest version of Mod_Cloudflare. This’ll ensure that Cloudflare works transparently by ensuring your IP Address is logged correctly in both Apache logs and web applications. In addition to this, Mod_Cloudflare will now also ensure that Flexible SSL will work transparently. In order to install Mod_Cloudflare please see the resources page.

In addition to this, be sure not to rate limit or block Cloudflare IPs. You can find a list of Cloudflare IPs here.

 

Install the WordPress Plugin

The official Cloudflare plugin for WordPress allows you to ensure your site is running optimally on the WordPress platform.

In order to install this plugin you’ll first need to login to your WordPress dashboard. Go to the plugins section, search ‘Cloudflare’, and install the WordPress plugin.

 

 

After the plugin has been installed click the Activate Plugin button. You can then go ahead and configure the plugin by going to Settings and clicking the Cloudflare menu option.

You’ll then be greeted by the login page where you can now enter in your credentials:

 

 

In order to find your API key, you can look in the drop down in the top right corner of your Cloudflare dashboard and click My Settings, the API key options will be under the Account > API Key section.

You will find the Global API Key panel on that Page:

 

 

Load Optimized Defaults

You can now enable the Optimized Defaults in the WordPress plugin so Cloudflare works optimally on your platform. You can do this by clicking the “Apply” button next to this setting.

Automatic Cache Purge will allow you to automatically flush the Cloudflare Cache when your WordPress site appearance is updated. You should enable this as well.

After following these steps, you can now go ahead and improve your security and performance by customizing your Cloudflare configuration. For more information, please check out the following articles:

Hardening WordPress Security

Caching Static HTML with WordPress/WooCommerce

Speed Up WordPress and Improve Performance

Review for Setting Up CDN for Your WordPress Website

What is a CDN?

CDN is short for Content Delivery Network which is a network of servers that deliver cached static content from websites to users based on the geographic location of the user.

By deploying your content across multiple geographically dispersed servers, you can make your pages load faster and create less of a chance for DDOS attacks.

Why do you need a CDN for your WordPress website?

There are many advantages to using a CDN, including:

  • Speed – the site runs faster.
  • Crash Resistance – traffic load is distributed to multiple servers thus making it less likely to crash.
  • Improved User Experience – a faster site means improved user experience.
  • Improvement in SEO –  site ranking improves once you optimize your site.

How do you set-up a CDN for your WordPress website?

CloudFlare is basically a Web Application Firewall, a distributed proxy server, and a content delivery network (CDN).

How to Setup CloudFlare for Your WordPress Site

Part 1: Create a Cloudflare account and add a website by following our step by step directions.

Part 2: Link your Cloudflare with your WordPress, by preparing your server, downloading the WordPress plugin, and loading optimized defaults.

Recommended Posts