Weird Caching problem

Weird Caching problem

Friday 27 January 2006 1:35:30 am - 2 replies

Author Message

Grenland Web (Jan Kudlicka)

Friday 27 January 2006 2:28:34 am

Hi Massimo,

the problem with your code is the following:

In the cache block you are using variable $node (for example in sub($node.depth,1)). This variable does not exist when the <i>content/view</i> view will use the cached version of the page (understand the result from the <i>content/view</i> view = the output of <i>/node/view/full.tpl</i> or its override).

When you remove the caches and you are accessing a page the first time, eZp has to render <i>/node/view/full.tpl</i> (or its override) first and the template system creates $node (which you are using in the template). The rendered page is then stored in the cache and the template system continues with rendering <i>pagelayout.tpl</i>. Because the cache-block does not exist, the code is processed and everything is fine because the template system still remembers the $node variable.

But once the cache-block has expired (= in 2 hours) and the template systems tries to process the code (of the cache-block) once again, the cached version of the page is used and that's why there is no $node.

<b>Solution: do not use $node.depth. Use $module_result.content_info.node_depth instead.</b>

Recommendation: there is no need to expire cache block in the time domain. Use expiry="0" in the cache-block. The cache-block will expiry only when any content on the site is (re-)published. (You can go even further and try to use the subtree_expiry parameter.)

Jan Kudlicka | System Developer @ Grenland Web | http://www.grenlandweb.no

Massimo Sanna

Friday 27 January 2006 2:32:49 am

Thank you thank you!
You solved my problem! Now it works ok!
And the trick of putting expiry=0 works flawlessly.
I also planned to use the subtree_expiry feature on some items which could benefit from it :)
I will pay you a beer hehe

Max

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.