XF 2.1 Cache contexts that are Enabled by default?

rdn

Well-known member
I assume these are all enabled?
  • css
  • registry
  • sessions
By just using this config:
PHP:
$config['cache']['enabled'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'host' => '127.0.0.1',
    'password' => 'password'
];

Only page contexts needs manual config addition?
 
Yes. Each cache call in the code can be configured as to whether it falls back to the default if not overwritten.

The page context does not do this, due to the likelihood that it may evict things like sessions and cause login difficulties if the cache is small or if there are a large number of guests active.
 
Thanks Mike!

How about Redis?
If I have 'persistent' => true

Do I need to configure 'persistent_id' => 'somestring' ?

Or I can leave 'persistent_id' => '' default?
 
@Mike
Please take a look at my config:
PHP:
// Global Cache
$config['cache']['sessions'] = true;
$config['cache']['enabled'] = true;
$config['cache']['namespace'] = 'xf_';

$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
    'host' => '127.0.0.1',
    'database' => 2,
    'persistent' => true,
    'persistent_id' => 'global'
];
// Global Cache

// Guest Page Cache
$config['pageCache']['enabled'] = true;
$config['pageCache']['recordSessionActivity'] = false;
$config['pageCache']['lifetime'] = 900;
$config['cache']['context']['page']['namespace'] = 'xff_';

$config['cache']['context']['page']['provider'] = 'Redis';
$config['cache']['context']['page']['config'] = [
    'host' => '127.0.0.1',
    'database' => 3,
    'persistent' => true,
    'persistent_id' => 'page'
];
// Guest Page Cache

Is everything correct?

Thanks!
 
Back
Top Bottom