A CDN can significantly improve site performance. I’ve home-spun a few in the past (using spare servers), but that’s not going to give the distributed performance boost of a truly localised CDN service.
We’ll be using KeyCDN for our CDN services. There are plenty of these services to choose from, but keyCDN offers a relatively inexpensive service and decent geolocation, and more importantly the ability to use on-demand SSL certificates for free via LetsEncrypt—which is critical if your site is already using SSL and you want to make use of a CDN.
First we create a Zone, and point this our primary domain (
mydomain.com). Ensure that SSL is enabled. No site should be running without SSL these days.
Now we can create a Zone Alias, which configures the subdomain we’ll be using on our site. Once created, this will provide us with the “real” domain (
mydomain-7b2b.kxcdn.com). We’ll need to add this to a CNAME record in our DNS in the next step.
Note, on KeyCDN, you can generate an SSL certificate for your domain (for free) by selecting LetsEncrypt from the SSL options.
Step 2, creating a subdomain
To avoid mixed content warnings (and future-proof our setup) we need to use SSL on our CDN because our main domain is also using SSL. We enabled SSL in step 1, but to make use of this, we’ll need to create an alias for it on our own DNS.
Via your DNS provider (in this case, Digital Ocean), create a new CNAME record
cdn.mydomain.com and point it at
It’ll take a while for this to propagate before the CDN will correctly be associated with your domain.
Step 3, configure WordPress
We’ll be using the WordPress Super Cache plugin here to do the work for us. Basically, it can rewrite the URLs of any assets you upload to WordPress to our newly created CDN.
All you have to do is enter the subdomain in the CDN tab.
Now we can test that it’s all working. Browse to the site and take a look at the networking tools. We should see our assets now being served via