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

Defining a Cache help

nodle

Well-known member
#1
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.
 

nodle

Well-known member
#5
Ok and do I need to add the code that I left out above also? This one:

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

RoldanLT

Well-known member
#7
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
 

nodle

Well-known member
#8
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?
 

nodle

Well-known member
#9
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. :(
 

nodle

Well-known member
#11
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?
 

RoldanLT

Well-known member
#12
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
 

Floren

Well-known member
#16
Yes, create it manually then chmod 777.
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
 

RoldanLT

Well-known member
#19
find /home/nginx/domains/phcorner.net/public/ -type d -exec chmod -R 755 {} \;
find /home/nginx/domains/phcorner.net/public/ -type f -exec chmod -R 644 {} \;
Yeah!
All uploads still working after setting this.
But still I'm not using this: $config['chmodWritableValue'] = 0644;
 

Floren

Well-known member
#20
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.