Menu theme suggestion ignored when cache turned on I have an alternative main menu that is used on specific node types.
When turning on the cache the menu block is cached. The theme suggestion for the menu is then ignored.

I tried to disable the menu cache by changing the block preprocess cache settings. But the menu block is not called when using hook_preprocess_block.

Also I tried to change the menu / block by using the hook_page_preprocess

function bootstrap_custom_preprocess_page(&amp;$variables) {
   //disable caches for every top header element
   //we do this as the dynamic header menu can't be cached - because of the landing page node type

   if(key_exists('top_header', $variables['page'])){
      foreach ($variables['page']['top_header'] as $key =&gt; $value){
        if(substr($key, 0, 1) !== '#'){
          $value['#cache']['max-age'] = 0;
        }
      }
   }
}


No success.
function bootstrap_custom_preprocess_block(&amp;$vars) {
    if($vars['derivative_plugin_id'] == 'header-navigation') {
        //-- This stops the block being cached in drupal 8
        $vars['#cache']['max-age'] = 0;
    }
}


This works for me. Block preprocess is correct.