← All modules

Magento 2 module

Context Topmenu

Lets the top navigation menu differ by customer context, such as customer group, without wrong menus being served from the cache.

Magento caches the top navigation menu so it does not have to be built again on every page view. This cache is the same for all visitors, even when other parts of the page differ by customer group, currency, language or similar visitor information. If your store shows different menu entries to different visitors (for example categories that are only visible to logged-in customers or to a B2B customer group), visitors can be shown a menu that was cached for somebody else.

This module solves that: the top menu is cached separately for each visitor context, using the same information that Magento’s full page cache already uses to tell visitors apart.

Features

  • The top menu is cached per visitor context instead of once for everyone.
  • Menus that depend on customer group, login status or other information that already separates the page cache are always shown correctly.
  • The menu stays cached, so the performance benefit of the menu cache is kept.

Configuration

There is nothing to configure. The module works right after installation.

Good to know

The module only changes how the menu is cached; it does not change which entries the menu contains. It is useful together with extensions or customizations that show different categories or menu entries to different customers.

Installation

Install the module with Composer in your Magento root directory:

composer require infrangible/m2-context-topmenu

Then enable it and update the store as described in the installation guide. Composer installs the required modules listed on this page automatically.