Forums / Developer / CacheBlock problem

CacheBlock problem

Author Message

Julien Plesniak

Monday 06 August 2007 6:53:44 am

Hello, i have a problem with the cache.

I have a template which contain this code:

{if not(ezhttp('modif'))}
   {def $modific = 0}
{else}
   {def $modific = 1}
{/if}

{cache-block keys=array($uri_string, $i, $modific)}
{if $i|eq(0)}
    Text A
{else}
    {if $modific|eq(0)}
       Text B
    {else}
       Text C
    {/if}
{/if}
{/cache-block}

When i go to mywebsite, i have $i = 0 so I see the "text A", but when i click on a button (wich switch $i = 1 in database) i didn't see the "text B" but always "text A".

When i disabled the cache, the site works perfectly , i see TextB.

i try to add a cache block (in the example) but it doesnt work.

Whats the problem?

Thanks for help

André R.

Monday 06 August 2007 9:10:16 am

Could you show how $i is defined ?

Btw there are some bugs in the code:
1. ezhttp produce error if the variable you are getting is unset.
2. I hope this is only example code, since that cache block is a wast of resources
(there is no point in caching two if's)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Xavier Dutoit

Monday 06 August 2007 9:14:20 am

Is it a template for a view (full...) ? in that case, you have to disable the cache for this template (set ttl = 0 ) otherwise the node is cached, and it doesn't take into account the cache-block in the template.

X+

http://www.sydesy.com

Julien Plesniak

Monday 06 August 2007 11:39:17 pm

Hello, i add before my cache block

{set-block scope=root variable=cache_ttl}0{/set-block}

and it work perfectly. Thanks :)

Ps: Yes André, it is an example, reduced to be read on the forum ;)

eZ debug

Timing: Jan 21 2025 02:48:13
Script start
Timing: Jan 21 2025 02:48:13
Module start 'content'
Timing: Jan 21 2025 02:48:14
Module end 'content'
Timing: Jan 21 2025 02:48:14
Script end

Main resources:

Total runtime0.9093 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0078 587.6094180.8438
Module start 'content' 0.00780.7748 768.4531616.3438
Module end 'content' 0.78260.1266 1,384.7969337.3828
Script end 0.9092  1,722.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4420210.0002
Check MTime0.00160.1707210.0001
Mysql Total
Database connection0.00110.118010.0011
Mysqli_queries0.831291.40511990.0042
Looping result0.00190.21361970.0000
Template Total0.877296.520.4386
Template load0.00250.279620.0013
Template processing0.874796.190920.4373
Template load and register function0.00020.020810.0002
states
state_id_array0.00080.090010.0008
state_identifier_array0.00130.143620.0007
Override
Cache load0.00220.2375270.0001
Sytem overhead
Fetch class attribute can translate value0.00160.170740.0004
Fetch class attribute name0.00100.110060.0002
XML
Image XML parsing0.00170.191740.0004
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00340.3769340.0001
String conversion0.00000.000930.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
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/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/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: 16
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs