If full HTML markup of mega menu region is cached number of database queries is reduced by 62 on all pages displaying this region.

Note: similar approach can be used to cache other regions like ‘Mid Footer Region’ Example implementation:


function wetkit_omega_preprocess_page(&$variables, $hook) {
  ...
  // Mega Menu Region.
  if (module_exists('menu_block') && empty($variables['page']['mega_menu'])) {
    $config = menu_block_get_config('main_menu');
    $data = menu_tree_build($config);
    $data['content']['#cache'] = array(
      'keys' => array('wetkit_mega_menu_region_content'),
      'expire' => CACHE_TEMPORARY,
      'granularity' => DRUPAL_CACHE_PER_PAGE, // unset this to cache globally
);
    $variables['page']['mega_menu'] = $data['content'];
  }
... }

Comments

sylus’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.