We all love WordPress for being user-friendly, free, and providing us with an easy way to market ourselves to the world. That is one reason why it powers over 29% of all the websites on the internet. Even Scotch.io is powered by WordPress!
WordPress can be quite a beast when it comes to web performance, however, it definitely is not the fastest platform out there. In fact most developers would probably prefer using a static site generator, which is becoming quite popular.
However, there are easy and cost effective ways to speed up WordPress without much work. One of them is to implement a CDN (Content Delivery Network). Check out the steps below to get a CDN up and running in only 2 steps!
Table of Contents
For example, let's say you have a website hosted with a provider and it sits in a datacenter in Dallas, TX. Every user that visits your site has to query all your website's assets from Dallas, TX, even those across the world. This introduces latency due to the long geographical distances. When you use a CDN it copies assets to a server closer. So let's say someone in the UK visits your site, instead of querying your assets from Dallas, TX, a CDN is now storing a copy of your assets on a server in London. This drastically reduces the latency and ISP hops for that user and makes your WordPress site load super fast!
Simply by adding a CDN I decreased load times by over 55%! - Brian Jackson
Essential Reading: Learn React from Scratch! (2019 Edition)
Besides increasing the speed of your WordPress site, a CDN also provides a lot of other benefits.
- ** SEO Benefits:** By increasing the speed of your WordPress site you should see an increase in your Google rankings. Remember that Google uses pagespeed as a ranking factor. Google can also index and crawl your images faster for Google image search.
- Scalability: A CDN lets you scale up and down quickly to be ready for sudden traffic spikes.
- Security: Mitigating DDoS attacks, secure token, SSL certs are just a few of the extra security measure you can benefit from with a CDN.
- ** Increase Conversions:** According to Kissmetrics, a 1 second delay can results in a 7% reduction in conversions.
- Lower Costs: By offloading traffic to a CDN you can save on bandwidth costs with your web host.
- Extra Caching: A CDN provides additional caching with features such as Origin Shield and cache-control headers.
- Gzip: Compression of your assets happens automatically when they are delivered from a CDN.
Check out these additional reasons why you should be using a WordPress CDN.
Now on to the fun part, how to actually install a CDN. Today, we will show you the quickest and easiest way to deploy a CDN on your WordPress site in just 2 simple steps!
In our example we are using KeyCDN, which is a content delivery network that features the lowest global prices at $0.04/GB. For most of you that is less than a cup of coffee per month! You can also check out other CDN providers at CDN Comparison. Some features I suggest looking out for are HTTP/2 support as well as Let's Encrypt integrations for free SSL certs.
First sign in to your KeyCDN dashboard. If you don't have an account yet you can signup here. Click into Zones and then New Zone. Give your zone a name, make sure Pull is selected for the Zone Type and then under the Origin URL put in your full domain name.
Optional: If your site is running on HTTPS, KeyCDN offers free SSL certs with Let's Encrypt. Simply select the Show Advanced Features and enable it with one click.
Now that we have your CDN account setup we just need to set it up on your WordPress site. The easiest way to do this is to install the free WordPress CDN enabler plugin. You can also use the CDN integration in popular caching plugins like WP Rocket, W3 Total Cache, and WP Super Cache. After installing, in your WordPress dashboard, click into Settings and CDN Enabler. You will want to put in your CDN URL, which you can find on your KeyCDN dashboard. Then press Save Changes.
You can take your configuration one step further and setup a custom Zone URL with your own domain name, like cdn.domain.com. This can be beneficial for SEO purposes, branding, and makes it easier to switch CDN providers later if you hardcoded anything (which you shouldn't be doing, but we all know it happens). Follow the steps below to setup a custom Zone URL.
The first thing you need to do is login to your domain registrar and create a CNAME record. In this example we are using NameCheap, but the process is almost identical with any other provider such as GoDaddy. First click into the Advanced DNS section on your domain and add a new CNAME record. For the host you will input what you want your subdomain to be. The most commonly used one is cdn. Then in the value you will put in your CDN zone URL. You can grab this from the KeyCDN dashboard.
Once you have the CNAME setup all you need to do is create a zonealias to let the CDN provider know. Simply click into Zonealiases and add a new one. The alias will be the subdomain you chose for the host of your CNAME. In our example we are using cdn.domain.com.
After mapping your zone to your CNAME then simply update the CDN URL in the WordPress CDN Enabler plugin settings.
And now all your assets will load from cdn.domain.com. It is recommended to fire up Chrome DevTools, jump into the network tab, and ensure that your assets are indeed loading from the new URL.
As you can see, setting up a CDN on your WordPress site is not hard at all! In fact, you can get it up and running in a matter of minutes and it won't break the bank. There are a lot of ways to optimize WordPress, but a CDN can give you instant results and users that come to your website from across the country will definitely appreciate it!
What are your thoughts on a CDN? Do you use one yet with your WordPress site? If so, we would love to hear your thoughts below.
Like this article? Follow @brianleejackson on Twitter