Menu Cache plugin for WordPress
Features
Caches the output of your menus. That’s it 😉
Specifically, it caches the output for every unique page. This allows the menus to retain the current/parent/child classes unlike most other menu caching plugins.
Why should I use this plugin?
If you want to cache your menu content obviously, but specifically if you want to cache your menu content and keep the current/parent/child page classes working. Most menu caching systems do not cater for keeping the various classes working, whereas this plugin does.
Why shouldn’t I use this plugin?
You should not use this plugin if you have a huge number of posts/pages on your site. The plugin caches each menu individually for each post. This can result in a huge number of cached menus on some sites, which could actually resulted in a slower site in those situations. It could also overload your object cache backend if it has insufficient memory to store them all.
Languages
- USA English
- Deutsch (German) – thanks to Alexander Praetorius for providing this translation.
Installation
Download the Menu Cache plugin.
- Upload the complete ‘menu-cache’ folder to the ‘/wp-content/plugins/’ directory OR install via the plugin installer
- Activate the plugin through the ‘Plugins’ menu in WordPress
- That’s it. The plugin is now working 🙂
Visit the Unique Headers Plugin for more information.
Frequently asked questions
Can I use this plugin to cache my widget areas too?
Nope. But luckily for you, Kaspars Dambis has created the Widget Output Cache plugin which does that for you.
How long are the menus cached for?
They are set to cache for one hour by default. You can change this by creating an extension plugin which extends the main plugin class and modifies the cache_time variable.
Why isn’t this baked into core WordPress?
Because it is not a good idea to cache a fresh menu for each page on some websites. If you don’t have many pages, then this is a perfectly acceptable way to handle menu caching. But if you have a large site with many pages, then there may be too many menus to efficiently cache.
Where is the options page?
There isn’t one. Just activate it and it should start working immediately. There is a cache purge button on the plugins page, but this should not be needed in normal usage.
Should I use this as well as WP Super Cache or W3 Total Cache?
Maybe. Those plugins do full static page caching. Caching your menus is only useful if your visitors are able to bypass the full page cache (this usually occurs when people comment or are logged in).
Your plugin doesn’t work!
It does work. If you think it is not working for some reason, please let me know why. Just because you can’t see any changes on your site, or it doesn’t “feel” faster does not mean that it is not working. In fact if you use the plugin incorrectly, your site could actually load more slowly than before. Caching is a complex thing and it can backfire on you if you don’t do it right.
Doesn’t an object caching plugin do this already?
Not quite. Object caching plugins are able to massively reduce the load created by WordPress menus, but not entirely. This plugin takes it a step further and caches the entire menu. Using the menu cache plugin in conjunction with an object caching plugin makes complete sense and is highly recommended for maximum performance.
Does it work in older versions of WordPress?
Probably, but I only actively support the latest version of WordPress. Support for older versions is purely by accident.
I need custom functionality. Can we pay you to build it for us?
No, I’m too busy. Having said that, if you are willing to pay me a small fortune then I could probably be persuaded. I’m also open to suggestions for improvements, so feel free to send me ideas and if you are lucky, it may be added for free 🙂
Changelog
Version 1.0.1 (4/1/2015): Added cache purge functionality and German language translation.
Version 1.0 (2/1/2015): Initial release.
Credits
Thanks to the following for help with the development of this plugin:
* Kaspars Dambis – Provided inspiration for this plugin via his Widget Output Cache plugin and the cache purge snippet used in his Minit plugin.
* Alexander Praetorius – Provided German language translations.
For a JS method of handling this problem, check out this Stack Exchange thread.
Paul says:
Hi Ryan, this looks great. I don\\\’t use full object caching because I have a cheap host on a shared server so although they haven\\\’t told me not too I\\\’m trying to be responsible. I do use transients a little on a selective basis though and I definitely think the menu is one area this could work well for me. Please can you tell me what you regard as lots of pages? I have no context for that. Are we talking hundreds, thousands, tens of thousands? Many thanks.
March 22, 2015 at 12:01 pm # //
Ryan says:
That depends on your object caching backend. Most have memory limits which you wouldn’t want to go over. If you don’t have an object caching backend installed, then WordPress will default to using the database which is almost unlimited in size, so the size limit wouldn’t apply then.
Every time you update the menu though, it will update the database for every single page, once per hour. So the limit would be however many times you can get away with writing to the database per hour, divided by the number of pages on your site. I don’t have a firm grasp on what that would be though.
March 22, 2015 at 12:17 pm # //
Paul says:
Okay thanks Ryan, my site traffic isn\’t that huge and certainly my menu structure wouldn\’t update that regularly so I\’d actually change hour to day or possibly even week timescales. I think I\’ll have a play and see how it goes. Thanks again.
March 22, 2015 at 12:43 pm # //
Ryan says:
It’s probably fine for most people to use, but I don’t want to go blanket recommending it when I know it has some underlying scaling issues.
March 22, 2015 at 3:48 pm # //