Compatible XF Versions:
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:
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 (
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,
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.
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.
Some sites you can use to test site performance:
- 1.4
- 1.5
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:
You must be registered for see links
I'm currently running Nginx by way of
You must be registered for see links
.3) Add expires headers (leverage browser caching).
See:
You must be registered for see links
4) Enable gzip compression.
See:
You must be registered for see links
5) Utilize front-end caching.
See:
You must be registered for see links
I use Zend OpCache for opcode caching (comes with PHP 5.5 or higher)
6) Utilize back-end caching.
See:
You must be registered for see links
I use Redis cache:
You must be registered for see links
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:
You must be registered for see links
DragonByte Optimise:
You must be registered for see links
Nginx fastcgi_cache:
You must be registered for see links
LiteSpeed cache:
You must be registered for see links
Cloudflare "Bypass Cache on Cookie" (Business and Enterprise plans only, $$$):
You must be registered for see links
Varnish cache:
You must be registered for see links
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:
You must be registered for see links
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:
You must be registered for see links
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:
You must be registered for see links
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 must be registered for see links
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:
You must be registered for see links
[bd] Attachment Store:
You must be registered for see links
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:
You must be registered for see links
[bd] Cache:
You must be registered for see links
DragonByte Optimise:
You must be registered for see links
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:
You must be registered for see links
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:
You must be registered for see links
GoodForNothing Image Optimizer:
You must be registered for see links
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 (
You must be registered for see links
and
You must be registered for see links
). 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,
You must be registered for see links
, 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:
You must be registered for see links
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:
You must be registered for see links
Without Pagespeed:
You must be registered for see links
20) If possible, use http/2.
See:
You must be registered for see links
21) If possible, use PHP7
See:
You must be registered for see links
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:
You must be registered for see links
23) Consider adding preload hints for web fonts (if you use them)
See:
You must be registered for see links
As always, make sure you test. Preloading web fonts may help or hinder performance depending on the rest of your setup.
See also:
You must be registered for see links
You must be registered for see links
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:
You must be registered for see links
You must be registered for see links
You must be registered for see links
You must be registered for see links