Make WordPress Core

Opened 9 years ago

Closed 20 months ago

#36225 closed enhancement (duplicate)

Cache wp_nav_menu with Transient API

Reported by: ianatkins's profile 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)

#1 @ocean90
9 years ago

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.

#2 @ianatkins
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.

Last edited 9 years ago by ianatkins (previous) (diff)

#3 @swissspidy
9 years ago

#36798 was marked as a duplicate.

#4 @lukecavanagh
9 years ago

I can see this as being a performance gain for WC stores with a fairly large menu built out.

#6 @tazotodua
8 years ago

Last edited 8 years ago by tazotodua (previous) (diff)

#7 @lukecavanagh
8 years ago

@ianatkins

This also works very well, using it on a client site.

https://github.com/inpsyde/menu-cache

#8 @szepe.viktor
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.

Version 0, edited 7 years ago by szepe.viktor (next)

#9 @tazotodua
7 years ago

it will be good if this topic will be ever implemented.

#10 @hellofromTonya
4 years ago

#41232 was marked as a duplicate.

#11 @spacedmonkey
20 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Marking as duplicate. #27120

Note: See TracTickets for help on using tickets.