Caching Large Navigation Menus in Drupal

While working on a project for Pega Systems, I had to deal with documentation organized into books, and some of the books had thousands of pages. Each page had a navigation menu listing every page in a large tree structure (nested HTML lists). The tree was collapsed, with just enough branches expanded to show the current page.

That's a lot of markup: UL and LI and A, oh my! Did I mention thousands of pages?

Generating that markup took a lot of work: database queries, PHP processing, theming ...

This talk will explain how I leveraged the cache system in Drupal 8, so that terrible, horrible, no-good page-load times became merely bad. The story has something for everyone:

  • A few lines of jQuery
  • A Twig template
  • A render array
  • Cache keys, cache contexts, and cache tags
  • Some SQL queries to show what is going on

Slides for this presentation (on GitLab Pages):

Session Slides
Attachment Size
Caching Large Navigation Menus.pdf 1.54 MB
Presentation Video