Be careful using $List('SiteTree') as your identifier for caching. On larger websites that have 100's / 1000's of pages and custom code which auto-saves pages etc you will find that this cache is being regenerated too often and not actually providing any benefit.

I prefer to write a cache key function that actually only updates navigation cache on items that have "Show in menu" ticked.

If you want to get really advance, you can add navigation layer caching in which it caches each parent of the navigation as well and only invalidates cache of the changed pages parents (all the way up). This is handy on large websites that have many pages in navigation as it will re-use the cache layers to regenerate the main navigation cache which is much faster.

Learning is good 😉 Thanks for the help!

👍 (1)

don't give up. And once you improved the time to first byte, page speed or lighthouse will find many other things to improve.

and of course: switch to live mode, otherwise partial caching is disabled in dev mode 😉

You might log your queries (or show them e.g. with the debug toolbar) to see what kind of queries are run too often

this is current key for your review: <% cached 'navigation', $ID, $List('SiteTree').max('LastEdited'), $List('SiteTree').count() %>