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.

-_-'

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

eZ debug

Timing: Jan 18 2025 02:04:24
Script start
Timing: Jan 18 2025 02:04:24
Module start 'layout'
Timing: Jan 18 2025 02:04:24
Module start 'content'
Timing: Jan 18 2025 02:04:25
Module end 'content'
Timing: Jan 18 2025 02:04:25
Script end

Main resources:

Total runtime1.5122 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.7969152.6094
Module start 'layout' 0.00540.0040 740.406339.4219
Module start 'content' 0.00941.5012 779.8281596.4297
Module end 'content' 1.51070.0014 1,376.257812.1875
Script end 1.5121  1,388.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2145160.0002
Check MTime0.00140.0933160.0001
Mysql Total
Database connection0.00080.050010.0008
Mysqli_queries1.452896.0735630.0231
Looping result0.00060.0395610.0000
Template Total1.477197.720.7386
Template load0.00200.134320.0010
Template processing1.475197.547520.7375
Template load and register function0.00020.013210.0002
states
state_id_array0.00090.058310.0009
state_identifier_array0.00140.093420.0007
Override
Cache load0.00170.1148370.0000
Sytem overhead
Fetch class attribute can translate value0.00090.060330.0003
Fetch class attribute name0.00080.055760.0001
XML
Image XML parsing0.00110.070630.0004
class_abstraction
Instantiating content class attribute0.00000.000860.0000
General
dbfile0.00150.1012220.0001
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs