3

i have a custom topmenu.phtml that adds a lot of load time to run on every page how can i make it get cached and only regenerate the menu html once a day? thanks I tried searching but am getting confused I have CE 1.7.0.2 and my caches (including full page) are enabled here is my Aoe Profiler run details

enter image description here

  • 1
    A full page cache would (obviously) cache this for you. If you want to cache the individual phtml file you'll need to write an extension that overrides that block and either loads from cache or renders from the template file. – Mikel Bitson Dec 29 '15 at 18:04
  • thank you for your input the full page cache IS already enabled why is it still taking all that time to load? – Yehuda Schwartz Dec 29 '15 at 18:06
  • 1
    If your FPC is on it will render this page once and store the page's html into a cache file. When you reload the page, it loads that html and sends it as a response instead of parsing the php for the response. This means that if you loaded the page with the profiler open, and during that first load the topmenu took that long to load, the html has been cached and you will see the profiler information with the topmenu taking a long time to load, even if this whole page loaded nearly instantly due to the FPC. Are you noticing pages load quickly after the first load? – Mikel Bitson Dec 29 '15 at 18:10
  • thank you for your time so all those EAV_COLLECTION_LOAD_ENT entries (their are about 50 of them and they each take ~10ms to run are not running evrey time i reload the page or go to a new page? – Yehuda Schwartz Dec 29 '15 at 18:14
  • 1
    It will run once per page it's loaded on to become cached. If you'd like that topmenu block to be cached only once and then shared across all pages, you'll need to modify the code of that phtml file (or overwrite it) to either render and cache itself or just read from that cache. – Mikel Bitson Dec 29 '15 at 18:19
3

If this is the default catalog.topnav block and an instance of Mage_Page_Block_Html_Topmenu, it's already cached for unlimited time (or until any category changes, thanks to cache tags). This is achieved with setCacheLifetime(false) in the constructor. If not, you can use layout XML to call setCacheLifetime(86400), which sets the lifetime to 1 day.

0

You can call:- Mage::app()->cleanCache(Mage_Core_Block_Template::CACHE_GROUP); And this will invalidate all cached template blocks including the top menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.