Question

I have a block that displays a random review in the footer. But when the BLOCK_HTML cache is active it is cached and does not display a random review.

I added the block in the theme local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
  <default>
    <!-- other stuff-->
    <reference name="footer">
      <!-- other stuff-->
      <block type="core/template" template="custom/random-review.phtml" name="random_review">
        <action method="setCacheLifetime"><s>null</s></action>
        <!-- <action method="setCacheLifetime"><s>0</s></action> I tried both, and I know the diffrence -->
      </block>
      <!-- other stuff-->
    </reference>
    <!-- other stuff-->
  </default>
  <!-- other stuff-->
</layout>

The template itself is mostly irrelevant to this question But I tried this in /template/custom/random-review.phtml:

<?php
echo rand (0,10000);
// the real template that fetches the random review.

It is called in /template/page/html/footer.phtml:

<!-- other footer stuff -->
<?php echo $this->getChildHtml('random_review') ?>
<?php //echo $this->getChildHtml('random_review', false)  // Also doesn't work ?>
<!-- other footer stuff -->

What am I missing here? Why is this block being cached?

Was it helpful?

Solution

Most probably your block is not cached.
The footer block is cached.
And since the footer contains your block it appears like it's cached.

You will need to change the cache key of your footer block.

Here is how you can do it or move your block outside the footer.

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