Opened 9 years ago
Closed 20 months ago
#36225 closed enhancement (duplicate)
Cache wp_nav_menu with Transient API
Reported by: | ianatkins | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4.2 |
Component: | Menus | Keywords: | |
Focuses: | performance | Cc: |
Description
Forgive me if I'm wrong but it looks like wp_nav_menu output isn't cached with the transient API. We're manually caching the output in our theme, then clearing the transient on the 'wp_update_nav_menu' hook.
For sites with caching plugins this is obviously redundant, but with dynamic pages (e.g. WooCommerce carts) this would be beneficial.
Change History (11)
#2
@
9 years ago
@ocean90 not a WordPress internal's pro, but could the caching not happen on line 452 of wp-includes/nav-menu-template.php - after the filter has been run?
Thanks for digging out the related tickets. Re ticket:27120:9 - whilst caching at a lower level is great, these menu's are relatively intensive to build and it's not uncommon for us to have 4-5 on a page on larger sites. Could be a nice perf gain for a lot of users.
#4
@
9 years ago
I can see this as being a performance gain for WC stores with a fairly large menu built out.
#5
@
9 years ago
here are plugins, will it help?
https://wordpress.org/plugins/menu-cache/
https://wordpress.org/plugins/wp-nav-menu-cache/
#6
@
8 years ago
Best solution is here - http://wordpress.stackexchange.com/a/232574/33667
#8
@
7 years ago
Core has a lot of caching done in object cache. See post caching for example.
My implementation also works with object cache although it will not work without one.
https://github.com/szepeviktor/tiny-cache/blob/master/tiny-nav-menu-cache.php
It has hooks for flushing the nav menu cache on menu editing.
Related: #27120, in particular ticket:27120:9.
I don't think that we can store the whole output of that function because it would bypass any filters which could be used by plugins.