Project

General

Profile

Feature #10728

Cache primary nav menu

Added by Boone Gorges 5 months ago. Updated 4 months ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
Performance
Target version:
Start date:
2018-11-19
Due date:
% Done:

0%

Estimated time:

Description

Ray, would you mind doing a bit of research into caching the primary nav menu? I'm unsure whether we can use an HTML fragment cache (unless we add JS for the current-page highlighting) but we can at least cache the two or three database hits that are triggered on every pageload.


Related issues

Related to CUNY Academic Commons - Feature #10788: Main query should be either cached or eliminated on primary siteResolved2018-12-05

History

#1 Updated by Boone Gorges 4 months ago

  • Related to Feature #10788: Main query should be either cached or eliminated on primary site added

#2 Updated by Boone Gorges 4 months ago

The plugin added in #10788 ought to fix this, but doesn't do so fully. This needs examination.

#3 Updated by Boone Gorges 4 months ago

  • Target version changed from 1.15 to 1.14.3

The unneeded query was bugging me so I had another look :)

The advanced-post-cache plugin doesn't work because wp_nav_menu() uses get_posts(), which suppresses filters, which in turn breaks the query caching.

I looked at a couple existing solutions and most were bad, but this one does roughly what I would've done had I built it myself: https://bjornjohansen.no/wordpress-menu-cache I've YOLOed it into production. My only concern is about invalidation, so let's keep our ears perked for reports. https://github.com/cuny-academic-commons/cac/commit/1ebcb300d4b39eb2fb628881f4cad7bd72984a95

#4 Updated by Boone Gorges 4 months ago

  • Status changed from Assigned to Resolved

I think this is working.

Also available in: Atom PDF