We use this module to build a mega menu for a website, because of the design the menu needs to be expanded up to 4 levels, and the page takes nearly 8 seconds for the first load after a cache clear, the second refresh serves from cache takes less time, but on a new page, the first load still takes nearly 8 seconds.
I managed to track this down to `getMenuLinkItemContent` method of `src/service/MenuLinkTreeHandler.php` file, it lists `url.path` and `url.query_args` as cache contexts, which means the link item content needs to be rebuilt every time for a new page, also this will populate the cache-store with considerable amount of cache for the same menu. The question is, is this data really necessary to vary by URL?
Comment | File | Size | Author |
---|---|---|---|
#9 | 3082978-8.patch | 6.14 KB | weynhamz |
|
Comments
Comment #2
weynhamzFor the moment, remove these two 'url.path' and 'url.query_args' contexts. I guess the better approach is to check how core `MenuLInkTree.php` handle the menu item caches.
Comment #3
weynhamzComment #4
weynhamzComment #5
ozinHi @weynhamz,
We will check the patch!
So what is the performance now?
Comment #6
weynhamzAfter clearing the cache, the first-page build still takes nearly 8 seconds, but after that, all the othe pages now takes 1~3s for TTFB without Varnish depending on the complexity of the page.
Comment #7
weynhamzAfter removing the above mentioned two cache contexts, the performance improved a lot, but it also brings another problem, the menu active link is cached as well. Attached the patch introduced a new cache context specifically for link item content, makes the cache varying by link active trail state.
Comment #9
weynhamzFix tests.
Comment #10
weynhamzComment #11
b_sharpe CreditAttribution: b_sharpe at ImageX commentedDefinitely needed! TTFB was getting killed on a site with a larger menu without this patch.
Comment #13
ozinBooom, cache improved! @weynhamz thanks for the patch
Comment #14
Heine CreditAttribution: Heine at LimoenGroen commentedThanks, I've tracked down massive cache bloat to this issue. The change has been pushed to 8.x-2.x, but constitutes a BC break on the changed signature of MenuLinkTreeHandlerInterface::processMenuLinkTree .
Shouldn't this be pushed to 8.x-3.x instead?