Forums / Developer / uncache elements

uncache elements

Author Message

Olivier Leloup

Tuesday 26 July 2011 3:14:46 am

Hello,

I try to uncache elements in many template (line_oi, full_oi). At moment, i try only on line_oi.tpl. (It's a list of object "oi")

Actually i have:

{cache-block keys=array($node.node_id,ezhttp('carnet','session'))}
     {if} {"link: add_to_notepad"}
     {else} {"link: remove_from_notepad"}
     {/if}
{cache-block}

That's work if ezpublish cache is clear, however if I add / remove several elements from my notepad (carnet), the links aren't displayed correctly, I think they are cached because i display before in pagelayout template "ezhttp('carnet','session')" and i have the right elements while in line_oi template, i have corrupted elements. If i clear ez publish cache, the links are display correctly.

I tried :

- to use set-block in full_rubrique, line_oi templates but no effect.

- to add properties to cache-block.

If you can help me, advise me or if you have any questions, I'm interested.

Thanks

Gaetano Giunta

Tuesday 26 July 2011 3:52:26 am

The problem is, I guess, that you are using your line_oi.tpl inside another node view template.

The caching basics in eZ is: the "view cache", part of the "content cache" stores one html chunk per node, when the page is accessed. The view cache is expired only when the node is edited, its children are edited, or related objects are edited.

Otoh the pagelayout (and templates included from it) is executed on every access.

Cache blocks are generally used to compensate this, eg. not to calculate on every page view the navigation menus, since they do not change frequently.

If you want to have a node view template that displays differently based upon some session variable for the user, you should in the first place deactivate the view cache for that node using this code:

{set-block scope=global variable=cache_ttl}XXX{/set-block}

(with XXX seconds), and only then think about introducing cache blocks.

More info:

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Features/View-caching

Principal Consultant International Business
Member of the Community Project Board

Nicolas Pastorino

Tuesday 26 July 2011 3:56:34 am

Hi Olivier, and welcome to the eZ Community, 

I am not sure whether you purposely simplified the code, but the {if} condition is missing the actual condition. Secondly : what type of data is stored in the session variable called 'carnet' ? An array ? A string ? Integer ?

Let us know,
Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Olivier Leloup

Tuesday 26 July 2011 7:58:20 am

Hi,

Thank you, the problem is solved.

I had other cache-block on other template (line_search_form.tpl).

Full_rubrique called Line_Search_Form and it called line_oi.

-_-'