Drupal is a registered trademark of Dries Buytaert

menu_cache

No security coverage
View on drupal.org

By default, menu blocks contain cache tags for each node that the menu links to, so that the menu can be invalidated if access to the node changes. This can result in a lot of cache tags for large menus and frequently invalidate large parts of a site if any of those nodes is saved.

Warning: This module is a proof of concept and attempts to optimize this by making several assumptions, it also depends on the following core issue #3485030: MenuTreeStorage shouldn't invalidate cache tags if the menu didn't change:

  • Caching is only optimized for anonymous users
  • It is assumed that anonymous users can access all published content and can not access unpublished content
  • Only node links and cache tags are supported and invalidated
  • It does not only support menu_link_content links as it uses the menu tree storage API, but will only find routed node links.
  • Menu link content entities are not saved when there is no real change to them, specifically this might currently not work with the token module or other modules that extend how menu_ui interacts with nodes

Do not use this on production yet without extensive testing. If any of those assumptions are not true for your site, menu links will either remain visible when they are inaccessible or not become visible when they should.

Future iterations will add the ability to customize those assumptions with alternative strategies. This will likely only happen once the depending core issue is fixed.

Additional Requirements

A patch for ##3485030: MenuTreeStorage shouldn't invalidate cache tags if the menu didn't change

Activity

Total releases
1
First release
Jan 2025
Latest release
1 year ago
Release cadence
Stability
0% stable

Releases

Version Type Release date
1.x-dev Dev Jan 10, 2025