1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Speed up your site with a CDN 2015-07-18

Use KeyCDN (Content Delivery Network) to cheaply accelerate your site

  1. Mouth
    Compatible XF Versions:
    • 1.3
    • 1.4
    • 1.5
    What is a CDN?
    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....
    1. Visit KeyCDN and click the 'Sign Up' button/link in the top right-hand corner, and create you 30 days free trial account.
    2. Activate your account, following the instructions emailed to you.
    3. One logged-in, on the left-hand side navigation menu, go to 'Zones'.
    4. Click '+New Zone'.
    5. Enter your Zone Name (eg. your XF Site Name), set your Zone Status to Active, and your Zone Type to Pull
    6. Enter your Origin URL being your XF site URL (eg. http://www.myXFsite.com)
    7. Click Save and return to the Zones page.
    Configure your XenForo site to use the CDN....
    1. Connect via SSH, SFTP, or FTP to your server
    2. Change to the 'library' folder of your site
    3. 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)
      // CDN support
      $config['externalDataUrl'] = 'http://[ZoneURL]/data';
      $config['javaScriptUrl'] = 'http://[ZoneURL]/js';
    4. Save the above addition to your config.php
    5. Login to your XenForo sites admin area (eg. http://www.myXFsite.com/admin.php)
    6. Navigate to Appearance -> Style Properties -> General
    7. 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>"
      Screen Shot 2015-07-18 at 19.38.30.png
    8. Click 'Update Style Properties' to save

    Your site is now using your CDN to deliver static files (style images, attachments, javascript, etc.) from servers closest to your users. Visit your Real-time Logs or Real-time Stats pages to see your site traffic using your CDN. Other reporting, such as Analytics and Geo Stats tells you how much data and from which locations your users are consuming your CDN.

    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? :)

Recent Reviews

  1. Jeffin
    Version: 2015-07-18
    Thank you for this guide and the quick help you provided to my question. I am currently testing this on 2 websites.
  2. CyclingTribe
    Version: 2015-07-18
    Testing this on my cooking forum as it gets visitors from around the world. Good guide and the walk-through worked as expected with the CDN set-up, in basic form, very quickly. Also got a $10 credit and am so far impressed with it. Thanks.
  3. mcatze
    Version: 2015-07-18
    This is an excellent guideline for setting up an xenforo with CDN. It was very helpful. Thanks a lot for that ..
    1. Mouth
      Author's Response
      Appreciated. Glad it helped.
  4. TRGCommunity
    Version: 2015-07-18
    Thank you so much for this great guide! I had a lot problems with setting up a CDN, but with your guide everything worked immediately without any issues. Thank you!
    1. Mouth
      Author's Response
      Glad it was helpful! Thanks for letting me now.