EE Full Page Cache Hole-Punching

Thanks for @Zifius for the idea to use EE Full Page Cache hole-punching for todays #tweetorial (the EE FCP in 8 tweets).

Add a etc/cache.xml file with a <config> root to your module. (see Enterprise/PageCache/etc/cache.xml). Choose a unique [placeholder] name.

The placeholders/[placeholder]/block node value must match the class-id of your custom dynamic block, e.g. mymodule/custom

The placeholders/[placeholder]/container node value is the class to generate the content dynamically and handle block level caching

The placeholders/[placeholder]/placeholder node value is a unique string to mark the dynamic parts in the cached page

placeholders/[placeholder]/cache_lifetime use to be ignored, but not anymore. For older instances specify a block cache lifetime in the container’s _saveCache() method instead.

Implement the container class and extends Enterprise_PageCache_Model_Container_Abstract. Use _renderBlock() to return the dynamic content.

Implement the _getCacheId() method to return a unique string. Use cookie values instead of model ids (lower cost).

Implement _saveCache() to simply return, or pass a cache lifetime value to the parent method. Voila, dynamic block done.

One last note: You DON’T have the full Magento App at your disposal when _renderBlock() is called. Be as conservative as possible.

  1. tweetorials posted this