xenforo speed performance

10 Tips on How to Speed Up XenForo Forum

XenForo Hosting $3.95/mo

Free migration. Optimized Xenforo Hosting

speed up xenforo

XenForo has brought a fresh outlook to forum software and is quickly becoming one of the most popular forum platforms around the globe. In this post, we will share with you techniques on ways you can speed up your XenForo forum to ensure fast load times for your visitors.

What is XenForo?

XenForo is a community forum software built on Zend Framework and was released in 2011. The software is developed and maintained by former vBulletin lead developers Kier Darby and Mike Sullivan.

According to Google Trends, activity around XenForo has been growing at a steady pace over the past four years, whereas vBulletin and Invision Power Board (IPBoard) have been declining.

XenForo is known for its easy pricing structure, built-in SEO, active development, fast support, as well as numerous add-ins available to accomplish almost any task.

Speed Up XenForo

Just as we described in our guide on how to speed up WordPress, XenForo can also become slow over time, especially because it is a community-based software. XenForo is much more resource heavy on your server and depending on your member activity, can be writing to your database constantly. Follow these steps below on how to speed up XenForo and keep it running fast, ensuring your visitors will return.

Speed Up Xenforo Index

  1. Content Delivery Network
  2. Utilize Caching
  3. Image Optimization
  4. jQuery CDN vs Local
  5. Minify CSS
  6. Defer Javascript (move to bottom)
  7. Fewer Add-Ons
  8. Reduce HTTP Requests
  9. Leverage Browser Caching
  10. Choose Fast Xenforo Hosting

1. Content Delivery Network

Implementing a Content Delivery Network (CDN) with XenForo is quick and easy. By doing this, you will ensure you are serving your assets (images, javascript, CSS) from multiple locations around the globe so they are delivered faster to your visitors. KeyCDN has a very simple integration with Xenforo.  Follow the steps below.CDN

      1. Create a pull zone in your KeyCDN account.
      2. Navigate to the document root of your XenForo installation.
      3. Add the following code to the file library/config.php using your CDN URL such as http://yourzone-ab12.kxcdn.com
        $config['externalDataUrl'] = 'http://yourzone-ab12.kxcdn.com/data';
        $config['javaScriptUrl'] = 'http://yourzone-ab12.kxcdn.com/js';
      4. Log in to your XenForo control panel and navigate to “Appearance” → “Styles” → [Your Style] → “Style Properties” → “General”.
      5. In the field “Path to Images” replace default “styles/default” with “http://yourzone-ab12.kxcdn.com/styles/default” and click on the “Update Style Properties” button to apply your new settings.

xenforo style properties

2. Utilize Caching

We highly recommend you utilize caching with your XenForo forum. You can do this by either using a caching add-on or by implementing the XenForo caching configuration, server side.

Caching Plugin

There is a popular add-on [bd] Cache from xfrocks.com that we recommend using. It can cache all of your built-in lists, views, and pages. It is possible to render a page with 0 database queries. Most people see page load times cut in half. This plugin works with back-end cache enabled or without.

Features of [bd] Cache

1. “Cache Pages” (guests only) for top speed
2. Admin can purge cache for individual page any time
3. “CSS to file” for faster serving, make it possible to put stylesheets behind CDN
4. “Defer JS” to make sure the page display in user browser as soon as possible.

If you are running Xenforo on a Redis server, here is a caching add-on: Zend Redis Cache

Server Side Caching

XenForo has documentation on how to define cache for both the front-end and the back-end.

Cache front-end

Configuring the front-end is easy, and involves simply adding the following lines to your library/config.php file.

$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';

You can also cache sessions by adding the following.

$config['cache']['cacheSessions'] = true;

Cache back-end

XenForo has three different caching methods you can implement for the backend.

  1. File back-end
    $config['cache']['backend'] = 'File';
  2. APC back-end
    $config['cache']['backend'] = 'Apc';
  3. Memcached back-end
    $config['cache']['backend'] = 'Memcached';
    $config['cache']['backendOptions'] = array(
    	'compression' => false,
    	'servers' => array(
    		array(
    			// your memcached server IP /address
    			'host' => 'localhost',
    			
    			// memcached port
    			'port' => 11211,
    		)
    	)
    );

LiteSpeed

Another recommended server-side option is to implement LiteSpeed. According to a case study from LiteSpeed, web server and MySQL optimization made ForoMTB’s XenForo installation 30x faster.

Now my board loads pages as if it were empty even with more than 3000 users connected.  – ForoMTB

speed up xenforo - case study

Before/After LiteSpeed + MySQL Optimization

3. Image Optimization

Just like with any website, image optimization is very important with XenForo. Especially when it comes to dealing with large image attachments in threads. By optimizing your images, you are ensuring the fastest rendering time for your pages and your saving disk space on your server.

We recommend the GoodForNothing Kraken add-on that optimizes and compresses attached images on your boards.

Processed 453k images, saved 134.9GB of disk space resulting in 55% reduction. – talkbass.com

You have two options when it comes to compressing. You can defer the compression of image attachments using an add-on like GoodForNothing Shell Defer or you can compress them upon upload, meaning your visitors will experience a slight delay.

4. jQuery CDN vs Local

Delivery jQuery via a CDN will most likely always be faster than local because you can distribute it from multiple locations that are closer to the visitor. XenForo has a built-in option to change where jQuery is loaded from. To change this go into “Options” → “Performance” and at the bottom there is a jQuery source selection. The Google CDN is a good one to start with.

jquery source cdn

5. Minify CSS

Xenforo has an option to minify CSS built-in. To enable this go into “Options” → “Performance” and enable “Minify CSS.”

xenforo minify css

The caching add-on [bd] Cache that we mentioned earlier also allows you to minify CSS.

6. Defer Javascript (move to bottom)

It is always recommended to defer javascript and place it right before the </body> tag. By default, XenForo loads javascript in the header that isn’t the best for speed and is not what is recommended by Google PageSpeed Insights.

There is a free add-on, Defer JS, which collects javascript in post-view output and moves them to the bottom of the page. This has a noticeable impact on page-load times as pending HTTP requests postpone the rendering of a page while scripts aren’t run anyways until everything is loaded.

Worked pretty well for me, increased my defer js from an F to a C! No longer failing 🙂 – Noobstradamus

You can also defer javascript using the [bd] Cache add-on we mentioned earlier.

7. Fewer Add-Ons

Just like with WordPress, the fewer plugins/add-ons in XenForo the better. Every add-on increases the number of HTTP requests you have as well as download times for whatever Javascript or CSS file they are including. While a lot of these optimization tips we have talked about are add-ons, we always recommend speed testing your forum to see if you are gaining speed or losing it, as some add-ons are more efficient than others. Ask yourself, do you really need the add-on or is it just a cool feature you could live without.

8. Reduce HTTP Requests

As we just mentioned above, always analyze the number of HTTP requests your XenForo forum is making. One little tweak we recommend is to remove the sidebar sharing. This is a simple way to increase your front page load time.

To do this browse to “Appearance” → “Styles” → [Your Style] → “Templates” and click into the “sidebar_share_page” template. Then simply delete its contents. Anytime you would like to re-add this to the sidebar, simply revert the template.

xenforo sidebar share page

By doing this, you will minimize DNS lookup on the front page.

9. Leverage Browser Caching

Another form of caching you can leverage is browser caching. See the following snippets you can add to your .htaccess file, such as enabling Gzip compression, adding expire headers, and disabling ETags.

Gzip Compression

Gzip compresses web pages and stylesheets at the server level before sending them over to the browser.

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Expire Headers

Expire headers tell the browser whether they should request a file from the server or grab it from the browser’s cache.

<ifModule mod_expires.c>
     ExpiresActive On
     ############################################
     ## Add default Expires header
     ## http://developer.yahoo.com/performance/rules.html#expires
     <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
     ExpiresDefault "access plus 1 year"
     </FilesMatch>
     </ifModule>

10. Choose Fast Xenforo Hosting

And last but not least, choosing fast Xenforo hosting can be one of the most important decisions you will make when trying to improve Xenforo performance. We recommend staying away from cheap shared hosting as they tend to overcrowd their servers and you will end up sharing resources between hundreds of people. We suggest going with a VPS like Digital OceanLinode, or Vultr. The reason is because you will be in complete control of your resources. And if you aren’t as tech savvy or don’t want to manage your servers via CLI, ServerPilot is a great control panel alternative which works with Xenforo and the VPS providers mentioned above.

Summary

As you can see, there are quite a few ways you can speed up XenForo. From implementing a CDN to caching, reducing HTTP requests, image optimization, minifying CSS, deferring javascript, and server level configs. Also having a good web host is equally important.

Do you have another way to speed up your XenForo forum that we missed? We would love to hear about it below in the comments.

original article: https://www.keycdn.com/blog/speed-up-xenforo/#caching