1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Xenforo plus APC plus Memcache?

Discussion in 'XenForo Questions and Support' started by Claudio, Aug 12, 2012.

  1. Claudio

    Claudio Well-Known Member

    Few days ago I saw a thread talking about how amazing was the speed using both software (APC and Memcache).

    I would like to implement this on my dedicate server, so I will appreciate if anybody can send me the link of the thread that has many explanations about this.
    I only found 2 threads that were created to ask some things, not to share the experience, that one is the one I´m looking for.

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    This is pretty much it:


    It all goes in library/config.php. You start by adding the frontend stuff:

    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
    // $config['cache']['cacheSessions'] = true;
    Then add a backend, which for APC is just:

    $config['cache']['backend'] = 'Apc';
    Or memcache:

    $config['cache']['backend'] = 'Memcached';
    $config['cache']['backendOptions'] = array(
    	'compression' => false,
    	'servers' => array(
    			// your memcached server IP /address
    			'host' => 'localhost',
    			// memcached port
    			'port' => 11211,
    Note that this config.php stuff is for storing cached data from XenForo. In addition, APC functions as an opcode cache which speeds up execution of the PHP code, but that happens by virtue of having APC installed on your server and doesn't require any configuration in XF.
    Eagle and dwdmadmac like this.
  3. Naatan

    Naatan Well-Known Member

    To be clear, this is far more trouble than it's worth unless you are running a very active site. Especially if you don't know much about memcache, APC or caching in general.
  4. Claudio

    Claudio Well-Known Member

    thanks guys, I know I can define this through config.php, but can I set both cache software at the same time?
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes you can.

    APC would be the opcode cache. Memcache would be the cache that you specify in the config.php file.
  6. RobinHood

    RobinHood Well-Known Member

    How active should a site be before considering switching from from APC to something more advanced like memcache?

    I'm guessing that's kind of a how long is a piece of string question because it will depend on your server specs too, but but for VPS or a basic dedicated server would you be looking at 100 concurrent users, 200, 500, 1,000, more?

    Also if there's a lot of images being uploaded and viewed do they get cached as well as posts using standard APC options?
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Say 100 concurrent users.

    APC (opcode cache) speeds up code execution. The memory cache that you setup in the config file stores the registry information (xf_data_registry table) as well as sessions if you enable it. Both caches can be used simultaneously if you want (opcode + memory cache).
    RobinHood likes this.
  8. RoldanLT

    RoldanLT Well-Known Member

    @Jake Bunce Why does we need to un comment this out:
    // $config['cache']['cacheSessions'] = true;

    If we would like to enable session ?
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    XF makes you manually enable session caching because if you enable it and your cache isn't healthy then users will have problems logging in.
  10. RoldanLT

    RoldanLT Well-Known Member

    I'm using Zend Opcache and Memcache, but only Memcache was declared on config.php.
    Is it fine i f I have this enabled: $config['cache']['cacheSessions'] = true;
    On config.php ?
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes, you can enable that in the config.php file. Nothing you have described about your setup is a problem. An opcode cache is different than a memory cache. You can use both. Only the memory cache requires specification in the library/config.php file.
    RoldanLT likes this.

Share This Page