My blog is running on a blazing fast Litespeed-powered server which is located in London, but because most of my visitors are from the US (check out this cool infographic!), I always wanted to setup CDN to speed things up for them too. A CDN can offer tremendous WordPress performance improvements and by utilizing the W3 Total Cache plugin you optimize WordPress from it’s core.
Since there wasn’t any related documentation available, Dediserve was very kind to offer me a free first month on their CDN service to test things out.
What is a CDN
A CDN is a global network of caching servers and smart DNS routing that delivers your content and media to your users from the closest possible location. The result is the fastest possible load times, better Google rankings and less load on your servers!
When US visitors view my blog, images are served from the UK, making it a long way from the visitor to the server. By implementing a CDN, edge servers located all around the world serve those images from the nearest location to the visitor. Dediserve is running on the OnApp CDN engine, and has over 60 locations all around the world at the time of writing.
Let’s get started – Setup the WordPress CDN resource
First of all, in order to setup CDN for your website, you’ll need access to your DNS records. I’ll cover the process with cPanel, but it should be as easy with any other hosting control panel, otherwise just ask your host to add the records to your zone.
I’m assuming you’ve already ordered your Dediserve CDN service so from within the Client Area, navigate to CDN, and click on Add new resource.
On the next page, specify the WordPress CDN hostname (eg. cdn.yourdomain.com), the origin domain (eg. www.yourdomain.com), select the Edge Groups which you want to cache your data and click on Create CDN Resource. I’m just using the Global option there, but you can select anything according to your needs. For example if you only have visitors from the US, and your server is located in LA, you can create a CDN resource for USA Central, and another one for USA East Coast.
Now note the CNAME, we’ll going to add it to our DNS Zone settings.
I’ve repeated the same steps 2 times more, to create media1.georgetasioulis.com and media2.georgetasioulis.com to better parallelize downloads across hostnames.
Add the CNAME records
If you’ve got cPanel just continue reading, otherwise skip this part and either use your control panel’s DNS functionality, or contact your host to add the CNAME for you.
Login into cPanel and click on Simple DNS Zone Editor.
On the Add a CNAME section, type the name (in my case cdn.georgetasioulis.com.) and CNAME from Dediserve. Here’s the complete list of my CNAMEs.
Wait!
Now we’ll just wait for the DNS changes to propagate around the web. This can take anywhere from a few minutes to 12-24 hours, depending on the TTL configuration of your DNS records.
Configure W3 Total Cache
I assume you’ve already have W3 Total Cache installed and configured for Page/DB Caching, so now just enable CDN and check the Generic Mirror option.
Next, click on the CDN tab, and configure the General settings as below (or you can make your own adjustments of course)
…and add the CNAME(s) you created on the previous steps.
Click on Save all changes, head over to the General tab and click on Empty all caches and you’re done!
Final thoughts
Implementing a WordPress CDN solution is very easy, and offers a huge speed improvement especially on users on different continents than the one your webserver is located. My front page now loads in 2s (from all 3 checkpoints) according to Pingdom Tools Full Page Test compared to 4s (from Amsterdam) and 5-6s (from the two USA checkpoints) before.
Dediserve also offers very competitive CDN pricing, charging a flat monthly fee of 4,95EUR plus 0,05EUR per GB. That’s 3-4 times cheaper than other Pay as you Go CDN providers like MediaTemple or SoftLayer (0.15/GB and 0.20/GB respectively).
Thanks for reading, if you were looking for a CDN solution for your WordPress blog, I highly recommend Dediserve, and in case you come up with any issues feel free to post a comment here (or you can always contact Dediserve’s top notch Support department :))
When I try this, my css and images do link to the CDN, but there is nothing at the cdn server, so they don’t load at all. Shouldn’t there be an extra step of uploading/syncing the media folders e.d. from your site to the dediserve servers?
Thx!
Hello Guido,
No, on Origin Pull type of CDNs you don’t need to sync your data with the CDN provider. This is done automatically.
Actually what happens it that when the browser requests the file:
http://media1.georgetasioulis.com/wp-content/uploads/somefile.jpg
the CDN will check if it has a cached version available, otherwise it will fetch it directly from the main server and then keep a local copy on the edge for next time.
This is why you need to provide a valid Origin URL when setting up your CDN account, exactly as I used my domain name as Origin URL during the CDN resource creation.