magento-2-mega-menu
magento-2-mega-menu copied to clipboard
New Feature - Dedicated MegaMenu Cache
Adds Dedicated Menu Cache to reduce page load down.
On a regular uncached page, the mega menu would need to load from the database, creating excess load and poor performance for page speed TTFB.
Changes add a cache to the System / Cache.
This means when Page Cache is flushed, it does not affect the mega menu cache and page TTFB.
Requires addtional changes to reneable the is active feature
Active class could do with some improvements. Currently a very very simple jQuery snippet
@kestraly Thanks for pushing your patch I have tried to check and see the time speed same my patch in file Block/Menu.php but my patch is keeping active current category. If possible you can check it and let me know. Thank you so much!
Tested your solution, but it's not sufficient
Real World Stats
1000 category store
Uncached Load Time 0.253178 seconds
Your Cached Version Load Time 0.201508 seconds
My Pull Request Load Time 0.003246 seconds
If we can improve the jQuery to addClass('active') to all the correct parents and children, it would be a perfect solution
@kestraly I have tested my solution and your solution when cache enabled, please check my result:
My patch: the code took 0.021853923797607 seconds to complete.
Your patch: The code took 0.59434199333191 seconds to complete.
I just add the method below to the file Block/Menu.php
public function toHtml()
{
$start = microtime(true);
$html = parent::toHtml();
$time_elapsed_secs = microtime(true) - $start;
echo "The code took " . $time_elapsed_secs . " seconds to complete.";
return $html;
}
note: Please let me know how to you test it.
I used the Magento profiler, which seemed to give pretty accurate results
I have tested with the Magento profiler. The second time when enabled cache your code still shows in the Magento profiler seems not a standard cache of Magento. The default Magento when caching the second time will not show in Magento profiler. If possible please check it and let me know.
To see the menu cache in action, you have to disable full page cache. Enable the Menu Cache and load the page two times. The first time to generate the menu cache, you will see an initial load. The page reload and you will see the templates for the menu .phtml files load in a fraction of time