Menu Caching


We all know that database calls are the main performance bottleneck in WordPress. What most people don’t know though, is how «expensive» in terms of performance the WordPress menus are.

This plugin will cache the menu HTML and show the cached version to your visitors, saving your database from far too many unnecessary calls.

Menu data are scattered across six(!) different database tables. When a user visits a page, an odyssey throughout the database begins.
In ‘wp_terms’, ‘wp_term_taxonomy’ and ‘wp_options’ tables we’ll find menu ID, slug and theme location. Then ‘wp_posts’ and ‘wp_postmeta’ to find menu’s nav items and their metas.
In the metas, we will find its targeted object, so let’s pay ‘wp_terms’ or ‘wp_posts’ a visit again to find the menu item’s target and ‘wp_termmeta’ to find its metas.

These are a lot of tables and even more database calls! When all required data is collected, the menu HTML is created and it is shown to the user.

The same process is repeated for every menu on the page. Desktop menu, mobile menu, some menus on the footer, a menu for the customer account on the header’s right next to the cart icon…

Imagine all these menus, some of them with decades of menu items, loading in every page for every visitor on your site.

Menu changes are very rare and this makes them an easy target for caching. Caching the generated menu HTML will prevent all these unnecessary database calls and greatly improve page loading times.

Full features list

  • Caches all classic WordPress menus to improve page loading time.
  • Enable/disable caching per menu.
  • Clear all menu cache with a button on the settings page.
  • Every time you edit a menu, its cache is automatically purged.
  • All cached data are automatically purged every 10 hours to keep everything fresh, like nonces etc.
  • Compatible with caching plugins like WPRocket, W3 Total Cache etc.
  • Compatible with most translation plugins. Tested ok with WPML and TranslatePress.

Cómo funciona

Everytime a user visits a page with a menu, WordPress collects all menu data from the database, and then runs a walker to create the menu’s HTML. Right before this generated HTML is returned to the user, the HTML is saved in the database in a transient.

Next time a user requests this specific menu, the saved HTML will be returned, instead of creating the menu from scratch.

Test results – How effective is it anyway?

If you use a good caching plugin and a certain page is served from cache, then you not see a difference in loading times. BUT… there are many cases when a page is not served from cache and it that scenario you will notice a huge difference.

Some of the scenarios when a page is not served from cache:

  • If you are not using a page caching plugin (Why not? Please install one!).
  • No existing cached version exists of the requested page. You benefit from menu caching during the first page load on every page, before the cached version is saved.
  • When users are logged-in. Even when using a per-user cache for logged-in users, menu caching is still super useful to quickly create the menu as the cache files are getting created.
  • On e-commerce sites on pages that can’t be cached by default, like cart, checkout, my account, wishlist etc.
  • In most e-commerce sites, when a customer adds something to cart, then serving pages from cache stops to prevent false data in the mini-cart.
  • On some AJAX requests that load page content that includes menus.

Let’s see the results from some tests run on a medium-to-large e-commerce site with a mega menu with many categories, a separate mobile menu and a couple more small menus.

For admin user:

  • Loading time for all menus – no menu caching: 0.46s (in average)
  • Loading time for all menus – with menu caching: 0.0015s (in average)
  • Speed benefit: 300+ times faster – menu loads almost instantly!

For incognito visitor:

  • Loading time for all menus – no menu caching: 0.232194 sec
  • Loading time for all menus – with menu caching: 0.001185 sec
  • Speed benefit: ~200 times faster – menu loads almost instantly!

Of course these numbers depend on your WordPress installation, your server setup and so many parameters but the outcome will be the same.

With menu caching, instead of building the menu everytime and losing precious time during page load, your menus will load instantly from cache.

Compatibilidad con los nuevos temas de «bloques»

Los menús en los nuevos temas de bloques se crean de una manera diferente a través del editor de bloques, y no a través del clásico nav builder que a todos nos encanta odiar. Este plugin no puede optimizar los menús creados con el nuevo editor de bloques. Sin embargo, no va a romper nada, no hará nada en absoluto. Si usas un tema clásico como el 99.9% de los sitios web WordPress, este plugin te será útil.

Hoja de ruta

Este plugin solo hace una cosa muy específica, caché de menús. No hay plan para añadir más características. Por supuesto, se implementarán pequeñas mejoras, y, si aparece algún fallo, trataré de corregirlo. Las siguientes versiones tratarán de ampliar la compatibilidad con los temas más populares.

A next update is already under development, intending to add compatibility with Woodmart theme.

If you have any good ideas about this plugin and yoy want to contribute, you can make a PR in the github repo.


  • Ajustes del plugin.
  • Speed improvement results.


  1. Download the plugin from Official WP Plugin Repository.
  2. Upload Plugin from your WP Dashboard ( Plugins>Add New>Upload Plugin ) the file.
  3. Activate the plugin through the ‘Plugins’ menu in WordPress Dashboard.
  4. Plugin’s settings are located inside Tools > Menu Caching.


How to activate menu caching?

You don’t have to do anything at all. As soon as you install and activate the plugin, menu caching starts working immediately. You can visit the plugin’s settings under Tools > Menu Caching to disable menu caching for a specific menu, or clear manually the cache.

Does it benefit my site if I use a page caching plugin?

Yes, it does. Pages in some circumstances are not sarved from cache, or a cached version is not available. In these scenarios menu caching greatly reduces page load time. For more info see the respective section in the description.

Can I clean the menus’ cache manually?

Yes, there is a button on the plugin’s settings under Tools > Menu Caching. You probably don’t need to, though. The cache auto-refreshes frequently, and also gets flushed after you edit a menu.

What about menus with links which contain nonces or any really special custom menu items?

Menu items like a logout link, contain a nonce for security reasons. Nonces are unique for each logged-in user session. This plugin detects automatically if a menu contains links with nonces and cache this specific menu separately for each user session.

If you still have any problem with caching of a menu, or you just don’t want to cache it for any reason, you can disable caching for this specific menu from the plugin’s settings.

Where are the cached data saved?

The cached menus are saved in the database in the ‘wp_options’ table as transients with a lifetime of 10 hours.

Why cache data are refreshing every 10 hours? Can I change that?

Cache gets automatically refreshed as a preventive measure, so that it never gets stale. Also, the 10 hours period prevents nonces from expiring, in case some of your menus contain some of them.

Can’t see why you want to change it but sure you can, using the ‘dc_wp_menu_caching_lifetime’ filter.

  add_filter( 'dc_wp_menu_caching_lifetime', function( $original_value ) { return $time_in_seconds; } );

¿Tienes problemas con algún menú en concreto después de activar este plugin?

Algunos temas hacen cosas raras a los menús. O quizás usas un plugin que añade funcionalidad extra a los menús, como mega menús, etc. Este plugin funciona bien con la mayoría de los temas y plugins por ahí, pero no puedo prometer la compatibilidad con cualquier cosa por ahí.

Si notas algo raro en un menú después de activar este plugin, por favor, ve a los ajustes de este plugin y desactiva el almacenamiento en caché para este menú específico.

¿Es compatible con los nuevos temas de bloques?

No, no lo es porque los menús en temas de bloques funcionan de una manera totalmente diferente. Sin embargo, no va a romper nada, no hará nada en absoluto, como llevar gafas de sol por la noche.


19 de julio de 2022 1 respuesta
Thanks for this plugin ! I’m currently trying to optimize some big e-commerce websites, and I installed the New Relic tool on our test server to analyze what is slowing done the page loading. Turns out the navbar menu generation is pretty heavy in Wordpress, with a big menu it adds around 500-600 ms on the page load. With this plugin on, it’s gone ! On the production website, we’re using WP Rocket, but some pages (cart, checkout, …) aren’t cached, and this is where this plugin is a must have. The compatibility with WP Rocket and WPML is a big plus ! My only concern now is that I hope the plugin author will continue to update it in the coming months/years, could you give me any informations about your plans regarding updates ? Thanks again anyway, very pleased by this easy 600ms win ! 🙂
6 de marzo de 2022 1 respuesta
Have never seen such care taken in releasing a little plugin like this. Beautiful, well thought out Description with NO Type-O’s! Beautiful UI. Everything working perfectly. No conflicts on a site currently running 53 other plugins! Sweet Plugin I hope goes far! Thanks Theo and Best Wishes! 5-Stars!
Leer todas las 4 reseñas

Colaboradores y desarrolladores

«Menu Caching» es un software de código abierto. Las siguientes personas han colaborado con este plugin.


«Menu Caching» está traducido en 2 idiomas. Gracias a los traductores por sus contribuciones.

Traduce «Menu Caching» a tu idioma.

¿Interesado en el desarrollo?

Revisa el código , echa un vistazo al repositorio SVN o suscríbete al registro de desarrollo por RSS.

Registro de cambios


  • Tested up to WP 6.5.x
  • Tested up to PHP 8.3
  • Bump minimum PHP version to 7.2 from 5.6
  • Minor code optimization.
  • Better prefix to JS global var to prevent conflicts in the global namespace.


  • Tested up to 6.3.


  • Tested up to 6.2.


  • Fix error during uninstallation.
  • Change hash generator to cover more cases and menu classes.
  • Save no-cache checkbox state for menus with non-english slug.


  • Initial Release