Support

Find answers, guides, and tutorials to supercharge your content delivery.

XenForo CDN Integration

Updated on April 12, 2019

XenForo is a commercial forum software released in 2011 by XenForo Limited and is developed and maintained by Kier Darby, Mike Sullivan, and Chris Deeming. It is written in PHP and intended for creating an engaging community experience.

How to complete a XenForo CDN integration

This integration guide demonstrates how to complete a XenForo CDN integration with KeyCDN. Follow the steps below to successfully integrate your XenForo application with KeyCDN:

XenForo 1.x

  1. Create a Pull Zone for the origin server.
  2. From the KeyCDN dashboard, navigate to Zones > Manage > Edit > Show Advanced Features. From here, configure the following setting:
    1. Ignore Query String setting to disabled
  3. Open the library/config.php file and add the following snippet, replacing https://examplepull-1a2b.kxcdn.com with your Zone URL:

    $config['externalDataUrl'] = 'https://examplepull-1a2b.kxcdn.com/data';
    $config['javaScriptUrl'] = 'https://examplepull-1a2b.kxcdn.com/js';
    
    NOTE: If your XenForo application is installed in a subdirectory include it in the file path.
  4. From the XenForo admin control panel, navigate to Appearance > Styles > [Your Style] > Style Properties > General > Settings. From here, prepend your Zone URL to the Path to Images setting:

  5. From the XenForo admin control panel, navigate to Appearance > Styles > [Your Style] > Style Properties > Header and Navigation > Settings. From here, prepend @imagePath to the Header Logo Image Path and Open Graph Logo settings:

  6. Verify the designated content is loading from KeyCDN. To check this inspect the HTML source code of your application, for example:

    <!DOCTYPE html>
    <html id="XenForo" lang="en-US" dir="LTR" class="Public NoJs LoggedIn Sidebar  Responsive" xmlns:fb="http://www.facebook.com/2008/fbml">
        <head>
    
            ...
    
            <script src="https://examplepull-1a2b.kxcdn.com/js/jquery/jquery-1.11.0.min.js"></script>
            <script src="https://examplepull-1a2b.kxcdn.com/js/xenforo/xenforo.js?_v=6ac1b348"></script>
            <link rel="apple-touch-icon" href="https://examplepull-1a2b.kxcdn.com/styles/example/og-image.png" />
    
            ...
    
            <meta property="og:image" content="https://examplepull-1a2b.kxcdn.com/styles/example/og-image.png" />
    
            ...
    
        </head>
        <body>
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/styles/example/xenforo/avatars/avatar_m.png" width="96" height="96" alt="keycdn" />
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/styles/example/xenforo/avatars/avatar_s.png" width="48" height="48" alt="keycdn" />
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/styles/example/logo.png" alt="XenForo CDN Integration" />
    
            ...
    
        </body>
    </html>
    
    NOTE: You can use a custom subdomain by creating a Zone Alias.

XenForo 2.x

  1. Create a Pull Zone for the origin server.
  2. From the KeyCDN dashboard, navigate to Zones > Manage > Edit > Show Advanced Features. From here, configure the following setting:
    1. Ignore Query String setting to disabled
  3. Open the src/config.php file and add the following snippet, replacing https://examplepull-1a2b.kxcdn.com with your Zone URL:

    $config['externalDataUrl'] = 'https://examplepull-1a2b.kxcdn.com/data';
    $config['javaScriptUrl'] = 'https://examplepull-1a2b.kxcdn.com/js';
    
    NOTE: If your XenForo application is installed in a subdirectory include it in the file path.
  4. From the XenForo admin control panel, navigate to Appearance > Style properties > Basic options. From here, prepend your Zone URL to the fields in use:

  5. Verify the designated content is loading from KeyCDN. To check this inspect the HTML source code of your application, for example:

    <!DOCTYPE html>
    <html id="XF" lang="en-US" dir="LTR">
        <head>
    
            ...
    
            <meta property="og:image" content="https://examplepull-1a2b.kxcdn.com/styles/example/og-image.png" />
            <meta property="twitter:image" content="https://examplepull-1a2b.kxcdn.com/styles/example/og-image.png" />
    
            ...
    
            <script src="https://examplepull-1a2b.kxcdn.com/js/xf/preamble.min.js?_v=cdb16b95"></script>
            <link rel="icon" type="image/png" href="https://examplepull-1a2b.kxcdn.com/styles/example/favicon.png" sizes="32x32" />
            <link rel="apple-touch-icon" href="https://examplepull-1a2b.kxcdn.com/styles/example/og-image.png" />
        </head>
        <body data-template="forum_list">
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/styles/example/logo.png"
                alt="XenForo CDN Integration"
                srcset="https://examplepull-1a2b.kxcdn.com/styles/example/logo@2x.png 2x" />
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/styles/example/logo.png"
                alt="XenForo CDN Integration"
                srcset="https://examplepull-1a2b.kxcdn.com/styles/example/logo@2x.png 2x" />
    
            ...
    
            <img src="https://examplepull-1a2b.kxcdn.com/data/avatars/s/0/1.jpg?1555083147"  alt="keycdn" class="avatar-u1-s" />
    
            ...
    
            <script src="https://examplepull-1a2b.kxcdn.com/js/vendor/jquery/jquery-3.3.1.min.js?_v=cdb16b95"></script>
            <script src="https://examplepull-1a2b.kxcdn.com/js/vendor/vendor-compiled.js?_v=cdb16b95"></script>
            <script src="https://examplepull-1a2b.kxcdn.com/js/xf/core-compiled.js?_v=cdb16b95"></script>
    
            ...
    
        </body>
    </html>
    
    NOTE: You can use a custom subdomain by creating a Zone Alias.

Upon completing this XenForo CDN integration, your XenForo application will deliver designated content from our global network. This will significantly improve the performance and user experience of your XenForo application. Adding a CDN to your XenForo application will bring your content as close as possible to your users, decreasing the overall latency of your application. Learn other ways to speed up XenForo.

Do you know of another integration approach with XenForo that we should mention here? Contact us to let us know and we will add it.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more about cookies.