1

I am using the Optimiseweb Cookie Notice module: http://www.magentocommerce.com/magento-connect/cookie-law-compliance-eu-uk-implied-consent-16757.html

I would need to disable the cache for the .phtml template. Here is the XML that takes care of loading the template file (as far as I understood):

<layout version="0.1.0">
    <default>

        <reference name="head">
            <action method="addCss" ifconfig="optimisewebcookienotice/general/enabled">
                <stylesheet>css/cookienotice.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <block type="cookienotice/notice" name="optimiseweb_cookienotice" as="OptimisewebCookienotice" template="optimiseweb/cookienotice/cookienotice.phtml" />
        </reference>

    </default>
</layout>

Edit: After the below comments, here is what I have now:

<layout version="0.1.0">

    <default>

        <reference name="optimiseweb_cookienotice">
            <action method="setCacheLifetime">
                <s>null</s>
            </action>
        </reference>

        <reference name="head">
            <action method="addCss" ifconfig="optimisewebcookienotice/general/enabled">
                <stylesheet>css/cookienotice.css</stylesheet>
            </action>
        </reference>

        <reference name="before_body_end">
            <block type="cookienotice/notice" name="optimiseweb_cookienotice" as="OptimisewebCookienotice" template="optimiseweb/cookienotice/cookienotice.phtml" />
        </reference>

    </default>

</layout>

Is there a way that I can force the template to be not cached?

I have tried to change the cache lifetime in the block contruct function like below but that did not work:

protected function _construct() {

    $this->addData(array(
        'cache_lifetime' => null
    ));
}

Thanks in advance for any help on this!

4
  • Not sure if it makes any difference but try 0 instead of null Commented Nov 14, 2014 at 9:08
  • I have tried many things there. 0, null, 1, -1 but nothing ever changed anything (I manually clear the cache after each change to be sure that my changes are reloaded).
    – MrUpsidown
    Commented Nov 14, 2014 at 9:10
  • 1
    Since you are running Enterprise edition, is it possible that it is not cached by the block cache, but by the full page cache?
    – mpaepper
    Commented Nov 14, 2014 at 10:04
  • I have to empty the Layouts cache type for my changes to be loaded. Refreshing the Page Cache has no effect.
    – MrUpsidown
    Commented Nov 14, 2014 at 12:34

1 Answer 1

2

you can use with xml like

You can use it

<reference name="your block">
    <action method="setCacheLifetime"><s>null</s></action>
</reference>

or

<reference name="your block">
    <action method="setCacheLifetime" />
</reference>

to set it to null.

or if you are using it by getChild then also pass as argument

You can disable cache in getChildHtml(). This is what the signature looks like:

public function getChildHtml($name = '', $useCache = true, $sorted = false)

This should do the trick:

echo $this->getChildHtml('block', false);
7
  • Thanks. What should "your block" be replaced with in my case?
    – MrUpsidown
    Commented Nov 14, 2014 at 9:59
  • You should not set it to 0, because 0 will invalidate the cache each time, but you still have the caching overhead. Null really is the value you want to have in there.
    – mpaepper
    Commented Nov 14, 2014 at 10:03
  • There is no layout.xml in the module. It is not called with getChildHtml either. I have tried with name="" but it didn't change anything either.
    – MrUpsidown
    Commented Nov 14, 2014 at 10:12
  • What you call layout.xml is the XML I posted in my question? I am very new to Magento, sorry.
    – MrUpsidown
    Commented Nov 14, 2014 at 12:42
  • Tried it. Still no change. See my question edit.
    – MrUpsidown
    Commented Nov 14, 2014 at 12:53

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.