Are you looking to speed up your WordPress site? If you’ve already ran through our other WordPress performance tips, another way to speed up your site is to integrate a content delivery network (CDN).
In this post, I’ll show step by step how to set up your very own WordPress CDN using KeyCDN. While KeyCDN is a paid service, they offer a free 30-day trial with no credit card required. So following this tutorial won’t cost you a dime to get started.
How Does a CDN Make Your WordPress Site Better?
We’ve written a number of posts about why you should use a CDN, so I won’t go too in-depth here.
Normally, when a visitor heads to your site, they have to download all of your site’s static assets from your server, no matter where in the world they’re located. So, even in Vietnam, I might have to download assets from, say, your New York server.
CDNs change that by mirroring your data around the globe. So instead of having to download from New York, I could grab those same assets from a Singapore data center. That means faster page load times and happier users.
If you want more in-depth thoughts, you can check out Joe’s KeyCDN review. But I like KeyCDN for a few different reasons:
- They offer a 30-day free trial with no credit card required.
- They have their own plugins which make integration easy.
- Their fees are low - from $0.04 per GB down to $0.01 per GB
That means if your site uses 100 GB of bandwidth in a month, you’re only on the hook for $4. Not too bad, right?
Of course, if low fees aren’t enough, you might want to check out my list of free CDNs.
And if you’re willing to pay a bit more, MaxCDN is another good option. It’s what Daan uses for wplift.
How to Set Up KeyCDN for WordPress
The process for setting up KeyCDN for WordPress is fairly straightforward. There’s only one part where it might get a little tricky because I’ll split the directions into two parts:
- One set if you’re using W3 Total Cache
- One set if you’re not. If you’re not using W3 Total Cache, I’ll show you how to do it using KeyCDN’s CDN Enabler plugin.
So once you get to Step 3 in the instructions below, make sure you follow the guide that applies to your site.
Step 1: Sign up For KeyCDN
Let’s start off slow - to get started, you first need to head on over to KeyCDN and sign up for an account. As I mentioned, you’ll get 30-days free without even needing to enter a credit card.
They’ll send a verification link to your email address, so make sure you click that to activate your account before continuing.
Step 2: Create a New Pull Zone
Pull zone is a weird term if you’re a beginner. I know it confused me at first.
But all it really means is that KeyCDN will copy your images/scripts to their own server so that they can distribute them globally. I guess they will “pull” your content onto their server. Got it?
Ok, so to do that, click on Zones:
Then, you need to enter the details for your new zone:
- Name - make sure you don’t make it something explicit :) It will be part of your public CDN URL. Also, make sure it’s all lowercase.
- Zone Status - make sure it’s active (that’s the default)
- Zone Type - make sure it’s set to “Pull”. Again, that should be the default
- Origin URL - just enter the base URL for your website
Once you’ve entered everything, click Save.
Then go grab a cup of coffee or scroll your Facebook feed while KeyCDN deploys your new zone:
Pay special attention to the “Zone URL” - you’ll need it for the next step. You should just go ahead and copy it to your clipboard.
Step 3.1: Connect KeyCDN to WordPress with W3 Total Cache
Once your zone is deployed, you’re ready to sync KeyCDN up with WordPress. This is the part where I’ll split the instructions in two.
First, I’ll show you how to do it with W3 Total Cache. Then, I’ll show you how to do it using KeyCDN’s CDN Enabler plugin. I’ll also show you two ways to use CDN Enabler because things can are a little different depending on whether you’re using HTTP or HTTPS.
If you’re using W3 Total Cache, go to Performance → General Settings and scroll down to the CDN section. Then, enable the CDN and choose the Generic Mirror option:
Make sure to save your settings. Then go to Performance → CDN. Scroll down to Configuration and enter your zone’s URL (remember - this is what I told you to copy to your clipboard in the previous step):
You can leave SSL Support as the default (Automatic). Then make sure to save your settings. And you’re all done! KeyCDN should start working right away. I’ll tell you how to verify that at the end of this post.
Step 3.2: Connect KeyCDN to WordPress with CDN Enabler
If you’re not using W3 Total Cache, you can use KeyCDN’s CDN Enabler plugin to set everything up.
It’s free, so you can install it directly from your WordPress dashboard:
Once it’s activated, head to Settings → CDN Enabler:
Assuming you’re using HTTP, then you just need to enter your Zone URL in the CDN URL box and make sure to save your settings. That’s all!
If you’re using HTTPS (if you’re not already, you can get a free SSL certificate), then you need to do things a little differently to ensure everything works:
First, you need to make sure you enable SSL for your pull zone in KeyCDN’s interface. To do that, go to Manage:
Then click Show Advanced Features, scroll down to the SSL area and choose Let’s Encrypt from the dropdown:
Then, when you configure Cache Enabler, make sure to enter your Zone URL as HTTPS and choose the Enable CDN for HTTPS connections option:
I know this is a bit complicated, but I’m trying to cover all potential scenarios here! If you haven’t installed an SSL certificate, literally all you need to do is enter your Zone URL in Cache Enabler and click save. Things only get a little more complicated if you’re using SSL.
Step 4: Verify That KeyCDN is Working Properly
If everything went according to plan, you should now see your images being loaded by KeyCDN, rather than your own server:
To verify that, you can just right-click on the image and inspect it with Developer Tools.
I know things got a bit hairy there with all of the different potential scenarios. But configuring KeyCDN for WordPress really is very simple. It should only take you about five minutes to get up and running.
If you have any questions regarding your specific situation, leave me a comment and I’ll try to help out!