We are using Magento EE 1.9.

In order to speed up a client website we are trying to fine tune the cache.

As you know Magento come with differnet cache technique.

In Magento EE we can use Full Page Cache coupled with the technique named "Hole Punching". As far as I understand this cache used some container to determine if a dynamic block should be retreive from the cache => applyWithoutApp($content) or if a dynamic block should be instantiated and rendered using $this->_renderBlock() => applyWithApp($content)

In order to do that you must declare in cache.xml the block you want to be "holepunched" with among other things its proper container class extending Enterprise_PageCache_Model_Container_Abstract In this container class you have to implement different function like _getIdentifier(), _getCacheId(), _renderBlock As you can see Contanier has is own cache ID.

As explained here

http://www.magentocommerce.com/wiki/5_-_modules_and_development/block_cache_and_html_ouput to cache a block you juste have to add data directly in the bloc's constructor by defining cache_lifetime,cache_tags,cache_key

class {NS}_{Module}_Block_{View} extends Mage_Core_Block_Template {

  protected function _construct()
  {
    $this->addData(array(
        'cache_lifetime'    => 120,
        'cache_tags'        => array(Mage_Catalog_Model_Product::CACHE_TAG . "_" . $this->getProduct()->getId()),
        'cache_key'         => $this->getProduct()->getId(),
    ));
  }
}

Edit with the fllowing post http://magebase.com/magento-tutorials/adding-cache-support-to-magento-blocks/

I've understand that static "cache_key" is just not sufficient . For these cas we should use the method getCacheKeyInfo:

 public function getCacheKeyInfo()
 {
     return array(
         'EXAMPLE_BLOCK',
         Mage::app()->getStore()->getId(),
         (int)Mage::app()->getStore()->isCurrentlySecure(),
         Mage::getDesign()->getPackageName(),
         Mage::getDesign()->getTheme('template')
     );
 }

All that said I go back to my questions: As I understand that FPC + hole punching seems a more complete solution for "caching". But what is the difference between full page caching (with hole punching) and "classical" block cache ?

-> As We are using Magento EE 1.9 should we only use FPC + hole punching ?
(Because in a way FPC + hole punching is already a way to cache block?)

  • Does it means that "classical" block caching is just outdated or only dedicated to users of the magento Comunity Edition?

-> or should we use both (FPC + hole punching and classical Block Caching)?

  • In this case what is the interest to set a cache id for a container when a block has his own cache key (or getCacheKeyInfo()) ?
  • In this case which one of these cache method is predominant ?

Thanks by advance fo all your answers !

1

There are 1 answers

0
Vinai On

Generally Magento uses a layered approach to caching: if a top level cache doesn't give a hit, then hopefully some low level caches make for a faster build-time for the response.

However, in regards to the Magento FPC, the usual block level caching is disabled automatically. The caching of the dynamic blocks is done on the FCP level. The process nevertheless involves the information from the gatCacheKeyInfo() method to build the cache key (and build a list of parameters for regenerating the block "without the app").

If you are using a different FCP from the EE one, it might well be the case that the usual block caching still can be used as a fall-back level of caching. IMO that approach would make sense.