It seems that by default Magento does not cache the majority of blocks.
I'm comfortable extending blocks and applying my own cache settings, but it seems odd that I would have to do this for the majority of everything.
Am I missing something or does it really take this much customization to really get the benefits of block level caching in Magento?
-
Caching is one of the key features of the Enterprise Edition - if you ask me. This is a economical decision, I think.– Fabian BlechschmidtCommented Feb 13, 2013 at 0:47
-
@FabianBlechschmidt: Is there much difference with block caching? I know there is the FPC in EE - which effectively disables block cache.– AlexCommented Feb 13, 2013 at 13:58
-
to be honest, no idea, but I heard good things about it.– Fabian BlechschmidtCommented Feb 13, 2013 at 14:55
-
Because Magento can NOT handle nested blocks !– Roger KeulenCommented Feb 20, 2016 at 17:26
2 Answers
Magento is a flexible system and so the core developers assumed that most blocks can change dynamically. When you figure out that in your specific use case (your specific shop) some blocks are more or less static, the easiest way to cache them for a while would be to overwrite the cache lifetime using a local.xml
file that you have place in your theme and the following snippet:
<reference name="name.of.the.block">
<action method="setCacheLifetime"><seconds>86400</seconds></action>
</reference>
-
Thanks! This is exactly the kind of thing for which I was hoping. Commented Feb 13, 2013 at 16:18
-
@JakeA.Smith: a note concerning your edit: It does not matter how you call the inside XML node. Just the order matters. You could even write
<foo>86400</foo>
– AlexCommented Feb 14, 2013 at 8:48 -
That only works with block with no dependencies. And blocks with no dependencies don't have to be cached. A round trip to REDIS takes more time than just: echo "your static string". Commented Feb 20, 2016 at 18:17
Seems like they went with the safest bet and not cache the majority of the blocks. The core team doesn't know what the end content of a block will be and how dynamic it is. Additionally, you could end up filling up your cache storage with all the variants of each block (e.g. number of products * websites * store views).
If you find yourself caching the majority of your blocks you may be better off with a full page cache solution such as Varnish or Akamai's Site Accelerator.