How to enable Cache for Xenforo


Sep 13, 2014
When you have a server with limited resource that many users accessing your system increasing daily and one day your server will be overloaded because it can not meet the needs from users. Also thinking about upgrading server system? first thing you should think about is, using CACHE. Cache makes your applications load faster because the processor has been previously saved and make your system run server softer. It is effective and why you should use the Cache. Also, using cache for Xenforo to help your forum save processing time and queries for the database, reducing server load, speed up loading time. XenForo capables to store and retrieve data different from a cache system, configured in config.php file in the library folder.

Xenforo cache has 2 types, Cache for front-end and back-end.

Depending on the software installed on your hosting provider, you can activate a cache system base or use more advanced scripts for storing data, such as APC (Alternative PHP Cache) or Memcached.

Front-End Cache

Setting Cache for front-end is very simple, you just add the following codes to your config.php file:

$config['cache']['enabled'] = true;
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
You can change the value 'cache_id_prefix' to suit the individual needs

For example:
$config['cache']['enabled'] = true;
$config['cache']['backend'] = 'File';
$config['cache']['backendOptions'] = array('cache_dir' => '/home/');
$config['cache']['frontend'] = 'Core';
$config['cache']['frontendOptions'] = array('caching' => true,'automatic_serialization' => true,'lifetime' => 3600);
If you want your forum read and store the sessions with cache, add this to your config.php file:

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

- Depending on your needs, you can change the options for front-end cache accordingly.
- When using the cache to store sessions to ensure there is enough space to store. If you need to increase space on your hosting, ask your web hosting provider for the support.
- Do not need to store sessions with Cache for Back-end if you use the APC cache.

Back-End Cache

One thing you should know, the type of caching, If storing cache with RAM is always better than hard drive storage on your server. Here are a few types of cache back-ends that you can use for Xenforo:

File Back-End

This is a simple back-end cache, it will store the data on hard disk as temporary files on your hosting/server.

How to set up to store as files:

$config['cache']['backend'] = 'File';
APC Back-End

If your server installed APC (Alternative PHP Cache) then this should add to the config file

$config['cache']['backend'] = 'Apc';
Note that some versions of APC may operate unstable, you should monitor your server for a while to ensure that it runs smoothly.

Memcached Back-End

Setting Memcached back-end as following:

$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
            // your memcached server IP /address
            'host' => 'localhost',
            // memcached port
            'port' => 11211,
Hope it helps and good luck!


New member
Jun 28, 2017
Damn, this is such a useful post, it deserves more exposure because I know that many people aren't using Cache for their Xenforo. I am definitely one of them...

I didn't know how to enable it because I don't have extensive experience but I was reading through the explanation on the official Xenforo page and now yours. I have to admit that yours is explained much clearer and simpler to understand. It also has far more details! A really big thank you for taking the time and effort for writing this. I'm going to try to enable the Cache and see if the system server runs better :)
Newer threads
Recommended threads

Latest postsNew threads

Referral contests

Referral link for :


Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.