magento-2-mega-menu icon indicating copy to clipboard operation
magento-2-mega-menu copied to clipboard

New Feature - Dedicated MegaMenu Cache

Open kestraly opened this issue 5 years ago • 8 comments
trafficstars

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

kestraly avatar Oct 21 '20 13:10 kestraly

Active class could do with some improvements. Currently a very very simple jQuery snippet

kestraly avatar Oct 21 '20 15:10 kestraly

@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!

magiccart avatar Oct 22 '20 03:10 magiccart

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

kestraly avatar Oct 22 '20 09:10 kestraly

If we can improve the jQuery to addClass('active') to all the correct parents and children, it would be a perfect solution

kestraly avatar Oct 22 '20 10:10 kestraly

@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.

magepow avatar Oct 30 '20 08:10 magepow

I used the Magento profiler, which seemed to give pretty accurate results

kestraly avatar Oct 30 '20 13:10 kestraly

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.

magepow avatar Nov 09 '20 16:11 magepow

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

kestraly avatar Nov 09 '20 17:11 kestraly