Question

How should I go about creating a list of phtml files that I would like to be excluded from the standard magento caching system?

*Some Context: I have a search bar in the header of a magento site. When a search term is entered another php file is rendered through ajax with a list of relevant results. When I turn off the block cache it works perfectly but when I don't turn it off the list of results appear as normal but if you click on them they all bring you to the same product. So unless I'm missing something I assume removing this phtml file from cache will fix my problems.

Was it helpful?

Solution

For that you need to set the Caching lifetime of the black behind it to zero. Inchoo did an article about this I used a long while back.

Basically you need to the following to the block

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

But please, read the article, it'll help you

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top