Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature - Dedicated MegaMenu Cache #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kestraly
Copy link

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
Copy link
Author

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

@kestraly kestraly mentioned this pull request Oct 21, 2020
@magiccart
Copy link
Collaborator

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

@kestraly
Copy link
Author

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
Copy link
Author

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

@magepow
Copy link
Collaborator

magepow commented Oct 30, 2020

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

@kestraly
Copy link
Author

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

@magepow
Copy link
Collaborator

magepow commented Nov 9, 2020

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.

@kestraly
Copy link
Author

kestraly commented Nov 9, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants