Want to subscribe to topics you're interested in?
Become a Member

Xenforo Optimising an caching XF

Discussion in 'Forum software usage' started by viralpoet, Mar 5, 2017.

  1. viralpoet

    viralpoet Member

    34
    3
    8
    Mar 5, 2017
    Ratings:
    +9
    Local Time:
    9:22 PM
    1.10.3
    10
    I've come from vpssim running xenforo with nginx, front end caching, back end memcached and opcache on the php files. It was quite well optimised, but now I need to change that to run under Centmin.

    I've noticed a few posts on caching and optimisation of XF, with Centmin but they are a little older. Whats the best optimisation now? I need it to work well as my servers are US, and the community is NZ based.

    Thanks also for the XF2 install - I can't belive how simple you made the whole process for me to follow.
     
    • Like Like x 1
  2. eva2000

    eva2000 Administrator Staff Member

    28,971
    6,575
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,759
    Local Time:
    7:22 PM
    Nginx 1.13.x
    MariaDB 5.5
    Yup if you're playing with Xenforo 2.0 Dev Preview releases, you'd want to read https://community.centminmod.com/posts/45274/ which will be updated as Xenforo 2.0 development goes on :)

    For Xenforo 1.5.x caching, PHP 5.6+ has Zend Opcache for opcode caching which is automatic so nothing to configure. For backend caching for Centmin Mod you have choices of:
    1. Memcached server is already installed by Centmin Mod
    2. Redis server caching and instructions on how to install Redis server (1st post).

    Xenforo Libmemcached/Memcached server backend cache



    For Centmin Mod LEMP web stack powered Xenforo forum which has Libememcach/Memcached PHP extension and Memcached server installed out of the box.

    As per official Xenforo manual, within your Xenforo library/config.php add or alter settings to the following, caching the cache_id_prefix value from xfxx_ to a unique one to each Xenforo installed instance on your server. So your library/config.php would have something like
    PHP:
    $config['cache']['enabled'] = true;
    $config['cache']['cacheSessions'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions'] = array(
    'caching' => true,
    'cache_id_prefix' => 'xfxx_',
    'automatic_serialization' => false,
    'lifetime' => 0
    );

    $config['cache']['backend'] = 'Libmemcached';

    $config['cache']['backendOptions'] = array(
    'servers' => array(
    array(
    'host' => '127.0.0.1',
    'port' => 11211,
    'weight' => 1
    )
    )
    );

    Xenforo Redis Cache Server backend cache via Zend Redis Cache Xenforo Addon



    For Centmin Mod LEMP web stack powered Xenforo forum which has Redis server support via REMI Yum repository installation and out of box Redis PHP extension support as outlined above. Be sure to install the Zend Redis Cache Xenforo Addon by Xon for this to work.

    You'll need to setup Redis server /etc/redis.conf as a LRU cache as outline at Using Redis as an LRU cache – Redis and in above 1st post. Basically. in /etc/redis.conf set a memory limit, eviction policy and LRU algorithm sample size.

    Example with 100MB max memory limit for Redis used as a LRU cache
    Code (Text):
    maxmemory 100mb
    maxmemory-policy allkeys-lru
    maxmemory-samples 10


    restart Redis server after making changes to /etc/redis.conf config file
    Code (Text):
    service redis restart


    As per FAQ Zend Redis Cache - FAQ | XenForo Community

    Within your Xenforo library/config.php add or alter settings to the following, caching the cache_id_prefix value from xfxx_ to a unique one to each Xenforo installed instance on your server

    PHP:
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xfxx_';
    $config['cache']['backend'] = 'Redis';
    $config['cache']['backendOptions'] = array(
           
    'server' => '127.0.0.1',
           
    'port' => 6379,
           
    'database' => 1,
           
    'connect_retries' => 2,
           
    'use_lua' => true,
           
    'compress_data' => 2,
           
    'read_timeout' => 1,
           
    'timeout' => 1,
       );
    require(
    XenForo_Application::getInstance()->getConfigDir().'/SV/RedisCache/Installer.php');
    Ensure to flush Redis server cache after change

    To flush all redis databases
    Code (Text):
    redis-cli FLUSHALL
    

    To flush just database 8 if you set it differently from default database 0
    Code (Text):
    redis-cli -n 8 flushdb


    You may need to re-login to your Xenforo forum. Browse your forums to populate the Redis cache and then check via PHP Redis Admin for database 0 or database 1 cache entries.
     
    Last edited: Mar 6, 2017
    • Like Like x 1
    • Informative Informative x 1