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.

-_-'

eZ debug

Timing: Jan 17 2025 23:44:30
Script start
Timing: Jan 17 2025 23:44:30
Module start 'content'
Timing: Jan 17 2025 23:44:30
Module end 'content'
Timing: Jan 17 2025 23:44:30
Script end

Main resources:

Total runtime0.7798 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 588.7266180.8516
Module start 'content' 0.00700.6462 769.5781601.4922
Module end 'content' 0.65320.1265 1,371.0703337.3828
Script end 0.7797  1,708.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.5545210.0002
Check MTime0.00160.2086210.0001
Mysql Total
Database connection0.00070.084110.0007
Mysqli_queries0.700389.80672000.0035
Looping result0.00340.44241980.0000
Template Total0.751396.420.3757
Template load0.00230.300620.0012
Template processing0.749096.047920.3745
Template load and register function0.00020.031510.0002
states
state_id_array0.00080.100710.0008
state_identifier_array0.00100.128620.0005
Override
Cache load0.00200.2586370.0001
Sytem overhead
Fetch class attribute can translate value0.00130.169340.0003
Fetch class attribute name0.00140.181360.0002
XML
Image XML parsing0.00140.176240.0003
class_abstraction
Instantiating content class attribute0.00000.001660.0000
General
dbfile0.00290.3693330.0001
String conversion0.00000.001030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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