7

In the admin/settings/performance page, I (the administrator) cannot enable or disable the block cache. Why?

6

As reported in that page for that setting:

Note that block caching is inactive when modules defining content access restrictions are enabled.

If there are modules implementing hook_node_grants(), the "Block cache" form field is disabled.

This is the code present in system_performance_settings(), which is the form builder for the "Performance" form:

$form['block_cache']['block_cache'] = array(
  '#type' => 'radios', 
  '#title' => t('Block cache'), 
  '#default_value' => variable_get('block_cache', CACHE_DISABLED), 
  '#options' => array(
    CACHE_DISABLED => t('Disabled'),
    CACHE_NORMAL => t('Enabled (recommended)'),
  ), 
  '#disabled' => count(module_implements('node_grants')), 
  '#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
);

As alternative, there could be a module that is disabling the form field to avoid the option can be selected; I don't know of any module that does that, even if I cannot exclude there is a module that is effectively doing it.

| improve this answer | |
7

I know you asked "why?" not "can i get around that problem"... but you can get around that problem without removing modules that use hook_node_grants(). Try out the Block Cache Alter module. It allows, among other things, the ability to use block caching even if modules implement hook_node_grants().

| improve this answer | |
  • Instead of using that module, adding $conf['block_cache_bypass_node_grants'] = TRUE; to settings.php should be investigated first if you know what you're doing with your blocks. – Niall Murphy Aug 11 '18 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.