Project

General

Profile

Actions

Feature #10728

closed

Cache primary nav menu

Added by Boone Gorges over 5 years ago. Updated over 5 years ago.

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

0%

Estimated time:
Deployment actions:

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 siteResolvedBoone Gorges2018-12-05

Actions
Related to CUNY Academic Commons - Bug #11473: My Commons link not present in Navigation on Groups pageResolvedBoone Gorges2019-05-17

Actions
Related to CUNY Academic Commons - Bug #19123: Inconsistent Menu Saving from Theme CustomizerResolved2023-10-27

Actions
Actions #1

Updated by Boone Gorges over 5 years ago

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

Updated by Boone Gorges over 5 years ago

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

Actions #3

Updated by Boone Gorges over 5 years 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

Actions #4

Updated by Boone Gorges over 5 years ago

  • Status changed from Assigned to Resolved

I think this is working.

Actions #5

Updated by Boone Gorges almost 5 years ago

  • Related to Bug #11473: My Commons link not present in Navigation on Groups page added
Actions #6

Updated by Boone Gorges 5 months ago

  • Related to Bug #19123: Inconsistent Menu Saving from Theme Customizer added
Actions

Also available in: Atom PDF