You will need to link a cache container to the core/messages
block to be able to prevent the block from caching. To reach your goal you will need a basic module, or add this to one of your existing module, whichever is the best (read: more logical) place for you.
Within your_module/etc/
you will need to create cache.xml
file:
<config>
<placeholders>
<your_module_messages>
<block>core/messages</block>
<placeholder>SYSTEM_MESSAGES</placeholder>
<container>Your_Module_Model_PageCache_NoCache</container>
</your_module_messages>
</placeholders>
</config>
The Your_Module_Model_PageCache_NoCache
needs to be an extend of Enterprise_PageCache_Model_Container_Abstract
and in that extend you need to overwrite the saveCache()
method and directly return $this
instead triggering the underlying $this->_saveCache()
. Perhaps with more logic you can make this punch hole a bit smarter, but for now assume that you never know when there is a new messages, thus leaving the hole open at all times.
public function saveCache($blockContent)
{
return $this;
}
The only thing left is to trigger Magento to load the core/messages
block from within the whole. This you can accomplish by adding the following method to your class.
protected function _renderBlock()
{
$block = $this->_placeholder->getAttribute('block');
//$template = $this->_placeholder->getAttribute('template');
$block = new $block;
//$block->setTemplate($template);
$block->setLayout(Mage::app()->getLayout());
return $block->toHtml();
}
It will fetch the block information from the cache.xml
file and return the output of the block. Since core/messages
actually generated it's own HTML you don't need to provide a template. So might as well remove those commented lines from the code.
Hopefully this helps you with your task at hand!