Chúc mừng Tết Trung Thu 15% off everything Shop the sale
Browse topics
Intermediate All add-ons

Speed up your XenForo forum

The changes that make the biggest difference to a slow forum, from PHP OPcache and a cache server to cron and keeping add-ons lean.

Updated 4 min read By the D.C Style team

On this page

Most slow XenForo forums get fast again with a handful of server-side changes, not with more add-ons or a bigger theme. Work through this list in order: the first steps cost nothing and make the biggest difference, the later ones help busy forums most.

Run a current PHP version with OPcache

XenForo 2.3 needs PHP 7.2 or newer, but recent PHP 8 releases run it faster and still receive security fixes. OPcache, a PHP extension, keeps compiled code in memory so PHP doesn't re-read every file on every page. Ask your host to run the newest PHP 8 version your add-ons support, with OPcache switched on. Find your XenForo, PHP and MySQL versions shows how to check what you have.

Note: Check add-on requirements before switching PHP. Google Drive Attachments, for example, needs PHP 8.1 or newer.

Add a cache server

By default XenForo asks the database for everything. A cache server such as Redis keeps frequently used data in memory instead. If your host offers Redis, add this to src/config.php, using the host and port they give you:

$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'host' => '127.0.0.1',
    'port' => 6379,
];

XenForo also supports Memcached, APCu and a filesystem cache through the same setting. Add $config['cache']['sessions'] = true; to keep sessions in the cache as well, which takes more load off the database on busy forums.

Cache whole pages for guests

Guests usually make up most of your traffic, and they all see the same pages. With a cache server in place, XenForo can store complete pages for visitors who aren't logged in and serve them without building them again:

$config['pageCache']['enabled'] = true;
$config['pageCache']['lifetime'] = 300;

The lifetime is in seconds. Logged-in members always get fresh pages. Page caching only works once $config['cache'] is set up, because that is where the pages are kept.

Run background jobs from the server

By default XenForo runs its background jobs, such as alerts, rebuilds and scheduled tasks, when visitors load pages. On a busy forum that adds work to real page views. Switch to Setup > Options > System and performance > Job run trigger > Server based trigger and have your server run this every minute:

php /path/to/xf/cmd.php xf:run-jobs

Set up the cron job before you change the option, or scheduled tasks will stop. Cron entries and the job runner walks through it.

Keep images a sensible size

Full-size phone photos are several megabytes each. In Setup > Options > Attachments, set Maximum attachment image dimensions so XenForo resizes large uploads, and consider Image optimization, which converts images to WebP on upload.

Be choosy with widgets and add-ons

Every widget on a page runs its own queries, and every active add-on adds a little work to each request. Remove widgets nobody looks at, and disable or uninstall add-ons you no longer use. Disable or uninstall an add-on. Keep the ones you keep up to date too: releases often include speed fixes. Widgets 1.1.5 Patch Level 5, for example, made the Random Threads widget much lighter on large forums.

Put a CDN in front of your forum

A CDN such as Cloudflare serves images, CSS and JavaScript from a server near each visitor. XenForo detects Cloudflare and tells Rocket Loader to leave its own scripts alone. If buttons or pop-ups stop working after you turn on a CDN feature, see finding JavaScript errors, and changes not showing if pages look out of date.

Still stuck? Open a support ticket with the pages that are slow and your PHP version. If a D.C Style add-on is involved, we'll look at it with you.

Did this guide help? Thanks! Glad it worked. Sorry about that. What went wrong? Thanks for telling us. We'll use it to improve this guide.

What went wrong?
Need a reply? Open a ticket instead.

Still stuck? Open a ticket