I have a block close to what the 'welcome' block in the header is but slightly different. Holepunching does not seem to be working for me I have mostly referred to this link.

Here's my code:

I have this block called in the layouts catalog.xml

<catalog_product_view translate="label">
    <label>Catalog Product View (Any)</label>
    <!-- Mage_Catalog -->
    <reference name="root">
        <action method="setTemplate"><template>page/newOneColumn.phtml</template></action>
        <block type="page/html_welcomeuser" name="welcome_user" template="page/html/welcomeuser.phtml" />
        <block type="core/text_list" name="top-nav" />

Here's my Main block: (Don't ask my Mage was overridden in local, its how it we got from third party)

class Mage_Page_Block_Html_Welcomeuser extends Mage_Core_Block_Template

     * @return type
    public function getCacheKeyInfo() {
      $info = parent::getCacheKeyInfo();
      $info['customer_id'] = Mage::getSingleton('customer/session')->getCustomerId();
      return $info;


The welcomuser.phtml:
- Has calls to get the username from a helper. excluded

Here's My Holepunching implementation:

Create new module attaching the cache.xml

<?xml version="1.0" encoding="UTF-8"?>

Coming to the Container:

class Mymodule_Holepunch_Model_Container_Welcomeuser extends Enterprise_PageCache_Model_Container_Abstract

    protected function _getIdentifier()
        Mage::log('Inside getIdentifier', null, 'cache.log');
        $cacheId = $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '')
            . '_'
            . $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER_LOGGED_IN, '');
        return $cacheId;

     * Get cache identifier
     * @return string
    protected function _getCacheId()
        Mage::log('Inside getCacheId', null, 'cache.log');
        return 'CONTAINER_WELCOMEUSER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier());

     * Render block content
     * @return string
    protected function _renderBlock()
        Mage::log('Inside renderBlock', null, 'cache.log');
        $blockClass = $this->_placeholder->getAttribute('block');
        $template = $this->_placeholder->getAttribute('template');

        $block = new $blockClass;
        return $block->toHtml();

    protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false; }    



  • The same "Hello firstname>" block (cached firsttime) appears to all users. Where am I going wrong? About to pull my hair over this. I am sure I am missing something?
  • If you observe I have put Mage::log statements in the container, but nothing seems to be logging.


Attaching config.xml of my holepunch Module:

<?xml version="1.0"?>
  • Btw: I am using Magento EE 1.11 – Curious Explorer Sep 11 '13 at 16:21
  • If not a solution.. Can someone help me debug ? Where exactly do I put my debug statements, lets assume Mage::log does not work (?) I'll use file_put_contents where do I put these statements ? – Curious Explorer Sep 12 '13 at 7:32
  • ok, I added some debugs to check the value of the FPC cache html, and it seems that the placeholder is not being put in the page. that means there is no Hole (it considers my block as a part of the page and put the entire value in cache). Now it boils down to why is the not treating this hole as dynamic ? – Curious Explorer Sep 12 '13 at 11:13
  • Another observation is : Even when (purposefully) causing a fatal error in the Container class, the same is not logged in exception.log and the results are same as before, so somehow its ignoring my container class completely. On Debugging app/code/core/Enterprise/PageCache/Model/Config.php where I put code to debug the getBlockPlaceholder function I do get a complete block like <!--{WELCOME_USER_a031623c7cc1206858ce0f2c546344ff}-->The content generated on first time. <!--/{WELCOME_USER_a031623c7cc1206858ce0f2c546344ff}--> – Curious Explorer Sep 13 '13 at 14:51
  • After a lot of head scratching I finally found the cause: There is a setting called "Minify HTML" in "Configuration" -> "Developer" -> "Minify HTML Settings" this was "Yes" thus causing it to remove the <!--{WELCOME_USER..> comments. – Curious Explorer Sep 20 '13 at 12:44

Ref: https://stackoverflow.com/questions/8126548/trying-get-dynamic-content-hole-punched-through-magentos-full-page-cache

The <name> in the cache.xml must match your blocks full name in the layout, not the alias, e.g. <name>product.info.example</name>

  • Thanks ProxiBlue, but the <name> in my cache.xml matches the layout block name i.e 'welcome_user' – Curious Explorer Sep 13 '13 at 12:07
  • Try and completely remove the name tag in your xml. I have hole punching working without that tag. Other than that, your code looks fine. Also add a constuctor in your Mymodule_Holepunch_Model_Container_Welcomeuser class and add some logging in that. It will give you a clue if the class is in fact instantiated. – ProxiBlue Sep 13 '13 at 12:19
  • Removing <name> did not seem to help, also I put in some debug in container class (added to constructor and all the methods) none of it is getting logged. – Curious Explorer Sep 13 '13 at 13:18
  • Sounds like your container class is not instantiated at all. Is the file path correct to it? (Mymodule_Holepunch_Model_Container_Welcomeuser) - taking case of filenames/folders into account – ProxiBlue Sep 13 '13 at 15:08
  • can you post your config.xml – ProxiBlue Sep 13 '13 at 15:09


Code Customization:

After a lot of head scratching I finally found the cause: A custom module developed by the third-party added a setting called "Minify HTML" in "Configuration" -> "Developer" -> "Minify HTML Settings" this was "Yes" thus causing it to remove the comments.

As Magento heavily depends on the Holes being identified through html comments, this removed all the blocks hence causing all the pain. This was done by the way by then using .. a observer to the "controller_action_postdispatch" event.

  • Ugh, yeah had that happen to me before, in 2012. By any chance this module: magentocommerce.com/magento-connect/html-minify-by-jemoon.html ? I noted to the developer the issue on that one. But it is due to CE module used in EE. – ProxiBlue May 7 '14 at 13:36
  • @ProxiBlue I'm experiencing something similar. Are you saying that by using a CE extension that it causes caching issues in EE? We just recently installed a CE extension that works but doesn't minify HTML or have anything to do with the username. – kel Oct 27 '14 at 22:53
  • @kel Depends on what the module does, cannot answer that in a blanket way. The issue mentioned here is that minification strips out comment blocks in the html. Magento EE uses comments in the HTML to effect hole punching. Stripping them out with minification causes hole punching to stop working. So, if this CE module removes comments from HTML, you will have the same issue – ProxiBlue Oct 28 '14 at 1:28
  • @ProxiBlue, that makes sense. Thanks for the info. – kel Oct 28 '14 at 15:01

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.