I'm getting a template via:

<?php echo $this->getChildHtml('ajaxCart'); ?>

and the block is declared like this:

<block type="page/html_topmenu" name="ajaxCart" as="ajaxCart" template="page/html/ajaxCart.phtml"/>

How can I remove this from our caching system?

1 Answer 1


If you are using the full page cache of Magento Enterprise, you need to do two things:

  1. disable block caching for the block
  2. exclude the block from otherwise cached pages with full page cache hole punching

1. Disable block caching

Change the block declaration to:

<block type="page/html_topmenu" name="ajaxCart" as="ajaxCart" template="page/html/ajaxCart.phtml">
    <action method="setCacheLifetime"></action>

This calls setCacheLifetime(null) and thus disables caching for the block.

More info about setCachelifetime() and how to use it in layout XML can be found here: http://fbrnc.net/blog/2015/06/cache-and-layout-xml-tricks

2. Hole punching

create a module with a etc/cache.xml file like this:

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

and the container model like this:

class Your_Module_Model_Container_Ajaxcart extends Enterprise_PageCache_Model_Container_Abstract
    protected function _renderBlock()
        $blockClass = $this->_placeholder->getAttribute('block');
        $template = $this->_placeholder->getAttribute('template');

        $block = new $blockClass;
        return $block->toHtml();
  • the block is still cached. Commented Jul 14, 2015 at 15:03
  • Are you talking about full page cache or block cache? Commented Jul 14, 2015 at 15:08
  • i'm using full page cache. Commented Jul 14, 2015 at 15:11
  • 1
    OK the answer applies only to block cache, will update it Commented Jul 14, 2015 at 15:13
  • 1
    Then the block probably relies on data that is not present when the page is loaded from cache. You will need to create a more sophisticated container. Please refer to techytalk.info/… for detailed explanation Commented Jul 14, 2015 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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