I am developing a custom module. In this module, I want to delete menu caches programmatically. For this, I have used

\Drupal::cache('menu')->invalidateAll(); // for clearing the menu cache      
\Drupal::service('plugin.manager.menu.link')->rebuild(); // rebuild the menu

But somehow, menu cache seems not being cleared and still the old menu is being displayed. How can I force Drupal to have my updated menu being displayed?


Menu's are displayed via blocks. You will probably have to clear the block render cache as well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.