Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
sylus CreditAttribution: sylus commentedCommit: http://drupalcode.org/project/wetkit_omega.git/commit/b485439