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

Defining a Cache help

Discussion in 'Server Configuration and Hosting' started by nodle, Jan 11, 2014.

  1. nodle

    nodle Well-Known Member

    I have been searching and reading all evening on enabling a front end cache and a back end cache. According to this:

    http://xenforo.com/help/cache/

    I just need to add the lines of code which I have. But one little part confuses me. Should I also add this line?

    Code:
    $config['cache']['cacheSessions'] = true;
    I added these:

    Code:
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
    $config['cache']['cacheSessions'] = true;
    Now according to this thread @Jake Bunce said it should be written to "cache_dir" under your tmp directory. But After enabling it this afternoon I am still not seeing any data or folder being created or written to. Is this because I didn't add the line of code listed above? Any help would be appreciated. I just want to make sure its working.
     
  2. RoldanLT

    RoldanLT Well-Known Member

  3. nodle

    nodle Well-Known Member

    So we have to define the cache directory? I thought it would just default to tmp?
     
  4. RoldanLT

    RoldanLT Well-Known Member

    Yes, create it manually then chmod 777.
     
  5. nodle

    nodle Well-Known Member

    Ok and do I need to add the code that I left out above also? This one:

    Code:
    $config['cache']['cacheSessions'] = true;
     
  6. RoldanLT

    RoldanLT Well-Known Member

    Yes if you'd like.
    It's better :)
     
  7. RoldanLT

    RoldanLT Well-Known Member

    This is what I'm using before:

    Code:
    // File Cache
    $config['cache']['backend'] = 'File';
    $config['cache']['backendOptions'] = array('cache_dir'  => '/home/public_html/internal_data/cache');
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions'] = array('caching'  =>  true,
                                                'automatic_serialization' => true,
                                                'lifetime'    => 1800
    );
    //End File Cache
     
  8. nodle

    nodle Well-Known Member

    What do these options do?

    Code:
    'automatic_serialization' => true,
                                                'lifetime'    => 1800
    Also if I create a folder to dump everything into. Does it manually remove the items that are no longer needed to use after a time?
     
  9. nodle

    nodle Well-Known Member

    I tried adding this but it just takes my site offline:

    Code:
    // File Cache
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
    $config['cache']['cacheSessions'] = true;
    $config['cache']['backend'] = 'File';
    $config['cache']['backendOptions'] ['cache_dir'] = '/home/tmp/xentmp';
    //End File Cache
    I created the xentmp folder with 777 permissions also. :(
     
  10. RoldanLT

    RoldanLT Well-Known Member

    Change this line; /home/tmp/xentmp to your forumroot/internal_dala/cache
     
  11. nodle

    nodle Well-Known Member

    Ok I created that folder in there as "cache" with 777 permissions. Then added this:

    Code:
    // File Cache
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions']['cache_id_prefix'] = 'xf_';
    $config['cache']['cacheSessions'] = true;
    $config['cache']['backend'] = 'File';
    $config['cache']['backendOptions'] ['cache_dir'] = '/home/public_html/internal_data/cache';
    //End File Cache
    But then I just get "An unexpected error occurred. Please try again later." Do I have to have APC installed first or something or should it just work?
     
  12. RoldanLT

    RoldanLT Well-Known Member

    Replace all your caching code on config.php with this:
    PHP:
    // Cache
    $config['cache']['enabled'] = true;
    $config['cache']['frontend'] = 'Core';
    $config['cache']['cacheSessions'] = true;

    // File Cache
    $config['cache']['backend'] = 'File';
    $config['cache']['backendOptions'] = array('cache_dir'  => '/home/fluxoid/public_html/internal_data/cache');
    $config['cache']['frontend'] = 'Core';
    $config['cache']['frontendOptions'] = array('caching'  =>  true,
                                                
    'automatic_serialization' => true,
                                                
    'lifetime'    => 1800,
                                                
    'cache_id_prefix'  =>  'fx_'
    );
    // End File Cache
    Assuming this is the correct/full path: /home/fluxoid/public_html/internal_data/cache
     
  13. nodle

    nodle Well-Known Member

    Ok I will try this. What are these options for?

     
  14. RoldanLT

    RoldanLT Well-Known Member

    I could't explain it more deeper sorry :)
    I guess it's built-in with Zend/XenForo :rolleyes:
     
  15. nodle

    nodle Well-Known Member

    Ok @RoldanLT I must had forgot my web name in my path. That fixed it. I appreciate all your help!
     
    RoldanLT likes this.
  16. Floren

    Floren Well-Known Member

    You should NEVER chmod a directory to 0777. XenForo has options to define proper permissions:
    $config['chmodWritableValue'] = 0644;
    Code:
    # ls -lah /var/www/html/data/
    total 20K
    drwxr-xr-x. 4 php-fpm root 4.0K Feb 21  2011 .
    drwxr-xr-x. 8 root    root 4.0K Dec 26 19:35 ..
    drwxr-xr-x. 3 php-fpm root 4.0K Feb 21  2011 attachments
    drwxr-xr-x. 5 php-fpm root 4.0K Oct 20  2010 avatars
    -rw-r--r--. 1 php-fpm root    1 Jun  9  2011 index.html
    # ls -lah /var/www/axivo.com/data/avatars/
    total 24K
    drwxr-xr-x. 5 php-fpm root 4.0K Oct 20  2010 .
    drwxr-xr-x. 4 php-fpm root 4.0K Feb 21  2011 ..
    -rw-r--r--. 1 php-fpm root    1 Oct 20  2010 index.html
    drwxr-xr-x. 6 php-fpm root 4.0K Jun 16  2013 l
    drwxr-xr-x. 6 php-fpm root 4.0K Jun 16  2013 m
    drwxr-xr-x. 6 php-fpm root 4.0K Jun 16  2013 s
     
    HittingSmoke and RoldanLT like this.
  17. RoldanLT

    RoldanLT Well-Known Member

    For files, How about for folders?
     
  18. Floren

    Floren Well-Known Member

    It does it for both, try it.
     
    RoldanLT likes this.
  19. RoldanLT

    RoldanLT Well-Known Member

    Yeah!
    All uploads still working after setting this.
    But still I'm not using this: $config['chmodWritableValue'] = 0644;
     
    Sheratan likes this.
  20. Floren

    Floren Well-Known Member

    The 'chmodWritableValue' forces the new added files to have proper permissions. :)
    In your case, this will not happen, you will get an error. This is what I do on my server:
    I own the directory with an PHP-FPM defined user, (in my case php-fpm, but could be apache, nginx etc., whatever you define in your php-fpm.conf). Then I insert 'chmodWritableValue' into config.php so all new directories and files will be either 0755 or 0644 and owned by PHP-FPM user.
     
    RoldanLT likes this.

Share This Page