Follow Brian Li (@DecryptoBL) on Twitter.
Follow Brian Li (@bwhli) on Instagram.

How to Set Up CloudFlare CDN on WordPress for Free

January 13, 2015

In this day and age, having a fast-loading website is crucial for both user experience and SEO. When it comes to site speed, there are a lot of optimizations to be made including finding the right web host, caching content, and optimizing images for the web. Using a content delivery network (CDN) can also significantly speed up your site.

Say your server is located somewhere in the United States. A visitor on the other side of the world may experience slow load times because of the physical distance. A CDN essentially caches static elements of your website, and sends them to different servers around the world. As a result, static content will be loaded from a geographically close server whenever someone visits your website.

There are tons of CDN options available, but CloudFlare has a free plan for small websites and blogs. By sitting between the visitor and your server, CloudFlare also helps protect your site from malicious hackers and bots. In this tutorial, I’ll show you how to set up CloudFlare on your WordPress site.

How to Set up CloudFlare

The first thing you need to do is create an account here. You’ll then be asked to provide the URL of your website, and CloudFlare will scan your website’s DNS records. While CloudFlare’s scan is almost always accurate, now would be a good time to login to your domain registrar to double check your A Record and CNAME. If you need to add or change a record, do so now. If everything looks fine, confirm and continue on with the setup process.

You’ll then be prompted to choose a plan. I’ve been using the free plan, but the paid ones do offer more options. I recommend the following initial CloudFlare settings.

  • SSL On
  • Performance – CDN + Basic Optimizations
  • Security – Medium

SSL encrypts all connections between the visitor and CloudFlare’s severs. CDN + Basic Optimizations will give you a good speed boost without compromising too much on cache timeouts. Medium security will protect you from malicious hackers and bots without too many false positives.

CloudFlare will then ask you to change your name servers. This allows CloudFlare to route malicious traffic through their servers before they get to your server. It also allows CloudFlare to serve cached static content.

If your domain registrar is BlueHost, your name servers will probably like…

  • ns1.bluehost.com
  • ns2.bluehost.com

CloudFlare will have you change them to something like this…

  • abc.ns.cloudflare.com
  • def.ns.cloudflare.com

Changing name servers can be done at your domain registrar. If you don’t know how to change your name servers, just Google “name of domain registrar change name servers”. Once you’ve updated your name servers, continue on and finish the setup process.

While waiting for the new name servers to fully propagate around the world, install the CloudFlare plugin on your WordPress site. After installation, go to CloudFlare settings under the Plugins tab, and fill in the relevant info.

  • CloudFlare Domain Name is the name of the site you signed up with or added.
  • Your CloudFlare API Key can be found under the Account tab on the CloudFlare website.
  • CloudFlare API Email is the email address you signed up with.
  • You don’t need to configure Development Mode right now.

CloudFlare should be all set up, you can begin to reap the benefits which include…

  • Protection from malicious hackers and bots.
  • Faster loading times through caching and minification.
  • Free SSL encryption.*
  • Sophisticated analytics reports.

If you need to change any settings or add websites, just go to the CloudFlare dashboard. This is also where you can go through analytics reports of your websites.

*CloudFlare’s free Flexible SSL encrypts connections between visitors and CloudFlare’s servers. It does not encrypt the connection between CloudFlare’s servers and your own servers. For full SSL support, a SSL certificate for your server needs to be purchased and installed.


Questions?

Find me on Twitter, or send me an email.