How To Add CDN to Your WordPress Blog Site

Recently as I have been tweaking, tuning, and pretty much been tinkering with my various blog sites I decided to jump into the realm of Content Delivery Network integration within WordPress.  So why is this something you may be interested in?  Well I for one tend to write articles with images and graphics.  I also have found that the faster your blog responds the better it is when google indexes your site maps.  My first move to Virtacore already increased my page loads significantly since I was off the shared hosting platforms that are available.  So once there I decided to take it to the next level.

What is a Content Delivery Network (CDN)?

Simply put, a CDN exists to just serve up your static content from multiple servers around the world.  The idea is that you can have “push” or “pull” zones to get your content to the network.  From there, it is replicated to localized servers around the globe.  When a person hits your pages the image content is provided to them by the nearest server, thus increasing response times.  With WordPress specifically this is pretty easy to set up

Setting up Your CDN Zones

The first thing you need is a CDN account.  Now I teamed up with a buddy Doug Smart over at Outsmart Computers to get some space on his CDN. He has an account with MaxCDN which is a division of NetDNA that he uses for his customers.  I have my own self-hosted sites so he simply setup pull zones on MaxCDN for me to use.  From there I just needed to create DNS CNAME’s for each domain to point to his domains.  So I have CNAME’s like this with his CDN hosting on the back-end.

  • cdn.chriscolotti.us
  • cdn.jaquilting.com
  • cdn.v-fit.us

Once the zones are setup they start pulling all the static content over and you can start getting WordPress configured to use the new file locations.  Below is a screen shot from the MaxCDN side of things provided by Doug.

Configuring W3TotalCache for CDN

This part is so super crazy easy it is scary.  First you need to install the W3TotalCache WordPress Plugin.  If you do not have it installed, it is pretty good and I will not go through all the other things it does.  Once installed enable the CDN function and select the provider you are using from the general settings. (Click images to enlarge)

Once you have it enabled you need to set up the connection.  Do this by going to the CDN option on the menu at the top.

Here is where you can decide what items you want to offload to the CDN for serving up.  You can usually leave the defaults, and depending on your CSS and JSS Minify items you can add those too.  You will need to experiment to see if you will have issues or not.  Remember these files will already be pulled into the CDN, so enabling or disabling just tells WordPress to get them locally or from the CDN.

Now you can add your CNAME you created and your API information so that the plugin can be allowed to purge the CDN remotely.  This is very useful especially for me since I am using someone else’s CDN account and allows me to purge it without calling them.

From here the best thing to do is run a test on WebPageTest.org to see if you need to add any advanced options.  I have found I did need to add some into the custom file list to pick up some added images and locations for various sites.  The last thing you do need to do it change the Browser Cache Setting to “Cache (Pubic).

That’s about it for a crash course on getting it working.  If you right-click any of my images you will see they are being served up by the CDN address.  you can extend this into SSL pages as well, but I currently have no need for that.  More detailed information is available on the MaxCDN site and from the W3TotalCache documentation.  The cool thing is once you are setup each new image will be pulled in and configured for you post by post.  You have nothing else to do except write your posts and upload your images.

 

About Chris Colotti

Chris is active on the VMUG and event speaking circuit and is available for many events if you want to reach out and ask. Previously to this he spent close to a decade working for VMware as a Principal Architect. Previous to his nine plus years at VMware, Chris was a System Administrator that evolved his career into a data center architect. Chris spends a lot of time mentoring co-workers and friends on the benefits of personal growth and professional development. Chris is also amongst the first VMware Certified Design Experts (VCDX#37), and author of multiple white papers. In his spare time he helps his wife Julie run her promotional products as the accountant, book keeper, and IT Support. Chris also believes in both a healthy body and healthy mind, and has become heavily involved with fitness as a Diamond Team Beachbody Coach using P90X and other Beachbody Programs. Although Technology is his day job, Chris is passionate about fitness after losing 60 pounds himself in the last few years.

Leave a Reply

Your email address will not be published. Required fields are marked *