- Compatible XF Versions 1.x
- 1.3, 1.4, 1.5
A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet. The goal of a CDN is to serve content to end-users with high availability and high performance. CDNs serve a large fraction of the Internet content today, including web objects (text, graphics and scripts), downloadable objects (media files, software, documents), applications (e-commerce, portals), live streaming media, on-demand streaming media, and social networks.
Content providers (eg. XenForo sites) pay CDN operators to deliver their content to their audience of end-users. Besides better performance and availability, CDNs also offload the traffic served directly from your own site, resulting in possible cost savings and load reduction on your server.
KeyCDN is a powerful and easy to use Content Delivery Network (CDN).
I have used several (MaxCDN, CDN77, Cloudfront), and found it to be the best and cheapest. It's Pay As You Go, so you only pay for what your site uses. They support SSL and SPDY, as well as your own site being HTTPS (not all CDN's do!). And best of all, it's only $0.04 per GB (for the first 10 TB) of CDN data used.
As an example, an average XF site with around 500k page view per month would use around 150GB CDN traffic costing you only approx. $6 per month.
Why Use a CDN?
The number one reason for using a CDN is to improve your user's experience in terms of speed, and as we know - speed matters! Ensuring a consistent experience for all your users is important.
Your XenForo site may be hosted in a particular region (where its's cheaper!), but have the majority of its users coming from an entirely different region - for example, if your site is hosted in North America, but if a good chunk of your users come from Europe or Australasia - their speed will not be as fast as it could be.
A global CDN would allow users from Europe or Australasia to download static content from a closer source. Instead of spanning the Atlantic ocean to retrieve data, they can connect to a server in say, London, Melbourne, to get the same data. This reduces latency and provides a faster loading of your XenForo community site.
CDNs not only ensure a faster experience to your users, but they also help to prevent site crashes in the event of traffic surges - CDNs help to distribute bandwidth across multiple servers, instead of allowing one server to handle all traffic.
Steps to setup a CDN for your XenForo site using KeyCDN
Create your CDN account, and setup your site within it....
- Visit KeyCDN and click the 'Sign Up' button/link in the top right-hand corner, and create you 30 days free trial account.
- Activate your account, following the instructions emailed to you.
- One logged-in, on the left-hand side navigation menu, go to 'Zones'.
- Click '+New Zone'.
- Enter your Zone Name (eg. your XF Site Name), set your Zone Status to Active, and your Zone Type to Pull
- Enter your Origin URL being your XF site URL (eg. http://www.myXFsite.com)
- Click Save and return to the Zones page.
- Connect via SSH, SFTP, or FTP to your server
- Change to the 'library' folder of your site
- Edit file 'config.php' and add the below two lines at the bottom, replacing [ZoneURL] with your Zone URL displayed on the Zones page. (eg. http://<MyXFSiteName>-fcc.kxcdn.com)
You don't have permission to view the code content.
- Save the above addition to your config.php
- Login to your XenForo sites admin area (eg. http://www.myXFsite.com/admin.php)
- Navigate to Appearance -> Style Properties -> General
- Within the 'Path to Images' field, add your Zone URL to the beginning. Eg. changing "styles/<yourstyle>" to "http://<MyXFSiteName>-fcc.kxcdn.com/styles/<yourstyle>"
- Click 'Update Style Properties' to save
If your site is HTTPS, then see this post in discussion for the advanced settings to use with shared SSL.
Before your free trial (and $5 bonus credit!) expires, visit the Payment page to buy additional credits for your account, using PayPal or your credit card.
Disclaimer: The links to KeyCDN are using an affiliate link that gives you $5 sign-up credit, and me a percentage of your first payment if you remain beyond the free trial period. Fair enough for writing this guide and steps eh?