xF1 Speed up your XenForo site

  • Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Radio

    ven0m

    Administrator
    Staff member
    Administrator
    Moderator
    Platinum
    xenForo 2.x.x
    xenForo 1.x.x
    Contributor
    vBulletin All Access Pass
    The Chest
    Verified
    Ultra Platinum VIP
    Platinum VIP
    Gold VIP
    Silver VIP
    Premium
    Member
    Jul 17, 2005
    20,466
    7,708
    321
    localhost
    Compatible XF Versions:
    • 1.4
    • 1.5
    I've been working pretty hard to get my XenForo forums speedy and thought I'd share some lessons learned here. This isn't meant to be comprehensive where I explain everything. More of a checklist.

    In each section, comments in italics refer to my current setup.

    Some of these are rather obvious, for example...

    1) Get a good host and a powerful server.

    I use and recommend Hivelocity, but there are lots of good hosts.

    2) If you have a dedicated server running Apache, disable httaccess. Move all httaccess directives to httpd.conf first so that you can keep any necessary rewrites in place.

    See:

    I'm currently running Nginx by way of .

    3) Add expires headers (leverage browser caching).

    See:

    4) Enable gzip compression.

    See:

    5) Utilize front-end caching.

    See:

    I use Zend OpCache for opcode caching (comes with PHP 5.5 or higher)

    6) Utilize back-end caching.

    See:

    I use Redis cache:

    7) Consider utilizing page caching for guests

    Caching pages for guests may help performance if a lot of your traffic is guest traffic. There are different ways to cache pages for guests depending on your setup:

    [bd] Cache:

    DragonByte Optimise:

    Nginx fastcgi_cache:

    LiteSpeed cache:

    Cloudflare "Bypass Cache on Cookie" (Business and Enterprise plans only, $$$):

    Varnish cache:

    I am currently not using any of these due to a variety of issues I encountered with some of them. But they can have a large impact on site speed.

    8) Tune MySQL (or MariaDB or Percona).

    See:

    Side note: I hired @MattW to setup my server, caching, MariaDB, and much more. Highly recommend his services! (no relationship other than happy customer). See:

    9) Don't use Google Integration.

    It's nice for members to be able to sign in with Google (OAuth), but there is a big hit to page loading speed. Not worth it to me. I also removed Facebook likes from thread pages because of a small associated performance hit from that.

    10) Disable unnecessary features and addons, especially if test sites such as Webpagetest.org show that they are slowing your page.

    11) Enable Minify CSS (under Options > Performance)

    The exception to this would be if you are already using something else to minify CSS, eg, [bd] Cache or DragonByte Optimise combined with either Pagespeed module or Cloudflare .

    12) Experiment with different jQuery sources (also under Options > Performance)

    See:

    I use Google as my jQuery source. It isn't the fastest in my testing, but it's likely that visitors will already have it cached.

    13) Delete the contents of sidebar_share_page template (social sharing) to increase front page load times. You can always revert if you want those back.

    14) Get rid of low-performing ad networks, and minimize the number of ad passbacks (redirects).

    In particular, try to avoid ads that block page render.

    15) Try a CDN to see if it makes a difference for your site. I've used MaxCDN, CloudFlare, CloudFront, and KeyCDN. All have their good and bad points.

    See:

    You can use Webpagetest.org to test site performance from different geographic regions.

    There are a couple addons which allow you to put your attachments on CDN:

    [Tinhte] Image Attachment Optimization & CDN Support:

    [bd] Attachment Store:

    Keep in mind that there is some risk involved if you use the [bd] addon to move your attachments to a new location. You become dependent on the developer to continue timely support. The Tinhte addon leaves your files in place and rewrites their URLs.

    Cloudflare will automatically serve attachments via CDN without needing either of the above two addons. Just use a custom page rule to cache the attachments in their edge servers. Here is the one I use:

    You must be registered for see images


    Putting Xenforo CSS on a CDN requires either [bd] Cache or DragonByte Optimise to convert CSS to file or the use of a Cloudflare custom pagerule to cache css.php*.

    16) Defer javascript to the extent possible without breaking your site. This can be done in a variety of ways, including mod_pagespeed or CloudFlare. There are also three addons that can do this for you:

    Defer JS:

    [bd] Cache:

    DragonByte Optimise:

    If you want to make sure that a particular javascript isn't called until after the page loads, you can use the method described here:

    I use the Defer JS addon to defer javascript.

    17) Optimize image attachments and avatars on your server.

    There are a couple addons which do this:

    [Nobita] Image Optimizer:

    GoodForNothing Image Optimizer:

    Tip: Make sure you have good backups of your attachments before using any image optimizer.

    18) Consider using an image delivery system which optimizes images further.

    One easy option is to use Cloudflare (Pro or higher tier) which has built in image optimization functions ( and ). Polish now includes the option to automatically convert images to webp for browsers which support that.

    If you use the Tinhte or [bd] addons mentioned above to put attachments on CDN, you can use one of the CDNs that do additional image optimization (resizing, webp conversion, etc). There are a number of companies which do this, including Cloudinary, Imgix, Imagefly, and others.

    One of these, , resizes and optimizes images based on detection of the visitor's device. Some of the others claim to do the same thing, but they require a lot more configuration including modifications to your Xenforo setup. ImageEngine works right out of the box. Very simple setup if you use it with the Tinhte addon.

    19) Try mod_pagespeed if you use Apache or ngx_pagespeed if you use Nginx.

    The Pagespeed module can do many different optimizations for html, css, javascript, and images.

    See:

    Pagespeed is a very effective way to resize images for mobile. Unlike ImageEngine it requires multiple page loads to optimize resources for mobile, but once it does so, the results are dramatic.

    With Pagespeed:

    Without Pagespeed:

    20) If possible, use http/2.

    See:

    21) If possible, use PHP7

    See:

    22) Leave automatic serialization off unless you use an addon that requires it.

    Code:
    $config['cache']['frontendOptions']['automatic_serialization'] = false;

    Note that you will need to clear your cache after changing this setting!

    See:

    23) Consider adding preload hints for web fonts (if you use them)

    See:

    As always, make sure you test. Preloading web fonts may help or hinder performance depending on the rest of your setup.

    See also:



    I use the following after the <head> tag in PAGE_CONTAINER to preload Lato and Font Awesome on my sites. Has definitely improved performance.

    Code:
    <link rel="preload" href="/styles/lato/1YwB1sO8YE1Lyjf12WNiUA.woff2" as="font" type="font/woff2" crossorigin>
    <link rel="preload" href="/styles/lato/H2DMvhDLycM56KNuAtbJYA.woff2" as="font" type="font/woff2" crossorigin>
    <link rel="preload" href="/styles/xenbase/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" type="font/woff2" crossorigin>

    Some sites you can use to test site performance:




     

    Attachments

    • 1.png
      1.png
      15.1 KB · Views: 0