How To Setup Hostgator Self Hosted CDN For W3 Total Cache

Content Delivery Network (CDN) services are cropping up left right and center given Google’s move to make the web faster than ever. Unfortunately these CDN services can be quite expensive especially for small time bloggers like me. An alternative to this whole CDN issue is to create a self hosted CDN i.e a CDN hosted on your current web hosting account. Most folks use sub domains as their CDNs and that’s what we will be doing in this guide.

This guide was created on a client’s blog running on Hostgator servers. The procedure might vary for other web hosts. We shall be creating a self hosted CDN for and linking it with a W3 Total Cache Installation.

Please pay attention closely as this guide creates a self hosted CDN for an addon domain but will address doing the same for a top level domain.

Table of Contents

Step 1

Log into your hostgator web hosting CPanel and scroll down to the Domains section. Click on Subdomains

Hostgator Subdomains


Select the domain you wish to create a CDN for and then specify the name of the CDN. I prefer cdn as shown below but you can choose whatever name you like.

Under document root, make sure it is set to public_html if you are creating a CDN for a top level domain. If it’s for an addondomain then it should be public_html/ Basically we are trying to make the self hosted CDN point to the root of your domain.

Click on create and you’ve succeesfully created your Hostgator powered self hosted CDN.

Self Hosted CDN Subdomain

Step 2

Log into your wordpress admin dashboard then go to Performance >> General Settings. Scroll down to the CDN section, enable it and select Generic Mirror as your CDN type.

Click on Save all settings.


Enable W3 Total Cache CDN

Step 3

Go to Performance >> CDN then scroll down to the part that says Configuration.

Leave SSL support as is unless you’re sure of what you’re doing.

Replace site’s hostname with: set this to the subdomain you created in the beginning.

Click on Test Mirror and if you get Test passed, all is well and you can proceed to save all settings.

W3 Total Cache CDN Generic Mirror Configuration


To ensure that all plugin JS, css etc files are loaded via the CDN, still under the CDN settings page, scroll down to Custom file list and add wp-content/plugins var yasrWindowVar = {"siteUrl":"https:\/\/","adminUrl":"https:\/\/\/wp-admin\/","ajaxurl":"https:\/\/\/wp-admin\/admin-ajax.php","visitorStatsEnabled":"yes","ajaxEnabled":"yes","loaderHtml":"

\u00a0 \"yasr-loader\"<\/div>","loaderUrl":"https:\/\/\/wp-content\/plugins\/yet-another-stars-rating\/includes\/img\/loader.gif","isUserLoggedIn":"false","isRtl":"false","starSingleForm":"\"star\"","starsPluralForm":"\"stars\"","textAfterVr":"\"[Total: %total_count% Average: %average%]\"","textRating":"\"Rating\"","textLoadRanking":"\"Loading, please wait\"","textVvStats":"\"out of 5 stars\"","textOrderBy":"\"Order by\"","textMostRated":"\"Most Rated\"","textHighestRated":"\"Highest Rated\"","textLeftColumnHeader":"\"Post\""};