How to enable Cache for Xenforo

marciayudkin

Member
Registered
Joined
Sep 13, 2014
Messages
34
Points
8
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:

Code:
$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:
Code:
$config['cache']['enabled'] = true;
$config['cache']['backend'] = 'File';
$config['cache']['backendOptions'] = array('cache_dir' => '/home/example.com/public_html/internal_data/cache/');
$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:

Code:
$config['cache']['cacheSessions'] = true;
Notes:

- 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:

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

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

Code:
$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:

Code:
$config['cache']['backend'] = 'Memcached';
$config['cache']['backendOptions'] = array(
    'compression' => false,
    'servers' => array(
        array(
            // your memcached server IP /address
            'host' => 'localhost',
 
            // memcached port
            'port' => 11211,
        )
    )
);
Hope it helps and good luck!
 
Newer Threads
Latest Threads
Replies
0
Views
115
Replies
0
Views
65
Replies
0
Views
57
Replies
1
Views
87
Recommended Threads
Replies
10
Views
3,433
Replies
24
Views
12,278
Replies
2
Views
2,904
Replies
25
Views
17,976

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

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.

Top