Forums / Developer / set-block = no cache won't work

set-block = no cache won't work

Author Message

Pablo Pernot

Friday 27 February 2009 8:12:22 am

{set-block scope=global variable=cache_ttl}0{/set-block} won't work.

version 4.0.3

site access settings :

[TemplateSettings]
TemplateCache=enabled
TemplateCompile=disabled
Debug=disabled
ShowXHTMLCode=disabled
ShowUsedTemplates=disabled

In the pagelayout template I get (no cache block) :
{include uri='design:random_background.tpl'}

and the random_background.tpl

{set-block scope=global variable=cache_ttl}0{/set-block}
{def $rand=rand(1,3)}
<body class="{concat('body-home-0',$rand)}">
<img src={concat('body-home-0',$rand,'.jpg')|ezimage()} id="background" width="100%" alt="" />
{undef $rand}

but the random part is cached. any clue ?

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Ivo Lukac

Friday 27 February 2009 9:18:13 am

AFAIK {set-block ...} is not needed here.
If there is no cache-block and the template is not inside module_result.content view cache mechanism ) it should work.

Did you try with TemplateCompile enabled?

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Pablo Pernot

Friday 27 February 2009 9:28:41 am

I worked with templatecompiled enabled "before". Do you think the cache is still there because templates are still compiled ? I disabled it, but maybe some templates compiled are still active ? I did --clear-all few times since. Is there a way to check if it is using compiled templates or not ?

What should be the best strategy ? Still keeping my random image into the page layout ? Adding cache-block into the template ?

thanks

 

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Steven E. Bailey

Friday 27 February 2009 1:45:36 pm

The Set block cache_ttl is for setting the view caching time not template caching. Do you have view caching enabled?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Pablo Pernot

Friday 27 February 2009 10:33:31 pm

Yes, I activated the viewcache. But nothing more, I mean I did not configured ant specific action or classes yet.

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Steven E. Bailey

Saturday 28 February 2009 12:00:50 am

I tried this by turning ViewCaching, TemplateCaching and TemplateCompile on in a test 4.03 environment and replacing my pagelayout with just:

{include uri='design:random_background.tpl'}

and making random_background.tpl:

{def $rand=rand(1,3)}
<html>
<font size="+6">{$rand}</font>
</html>

Which created a var/<plain>/cache/template/compiled/random_background-<hash> file the first time I loaded. Where the $rand was loaded in that file, it was still a variable - not hard-coded.

The random number was never cached - whether the set-block was there or not.

So, I think if you can test like this, do it and see for yourself if it is caching or not.

Otherwise, are you sure you are testing what you think you are testing and are you sure you aren't being tricked by your local browser cache?

Or, I wrapped the stuff in random_background.tpl in a cache-block with a uri key - *THEN* it was cached - so are you absolutely sure that your include isn't in a cache-block?

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Pablo Pernot

Wednesday 04 March 2009 5:13:13 am

Thanks a lot

Yes I found that in the compiled template, but obviously the compiled template isn't used because If I'm adding some stuff (var_dump, exit, few other funny things...) nothing happened. It is not my browser cache, nor any other proxy / cache ? any idea ?

// def $rand
unset( $var );
if (! isset( $var ) ) $var = NULL;
while ( is_object( $var ) and method_exists( $var, 'templateValue' ) )
$var = $var->templateValue();
$varData = array( 'value' => $var );
$tpl->processOperator( 'rand',
array (
0 =>
array (
0 =>
array (
0 => 2,
1 => 1,
2 => false,
),
),
1 =>
array (
0 =>
array (
0 => 2,
1 => 3,
2 => false,
),
),
),
$rootNamespace, $currentNamespace, $varData, false, false
);
$var = $varData['value'];
unset( $varData );
if (! isset( $var ) ) $var = NULL;
while ( is_object( $var ) and method_exists( $var, 'templateValue' ) )
$var = $var->templateValue();
if ( $tpl->hasVariable( 'rand', $rootNamespace ) )
{
$tpl->warning( 'def', "Variable 'rand' is already defined." );
....

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

Pablo Pernot

Wednesday 04 March 2009 7:01:12 am

Ok.

sorry all for the inconvenience...

I discovered a cache-block not closed... and things run fine now...

BTW I know now the complete tree of var/cache.

Pablo Pernot
http://www.smartview.fr
http://www.areyouagile.com

eZ debug

Timing: Jan 18 2025 11:30:42
Script start
Timing: Jan 18 2025 11:30:42
Module start 'content'
Timing: Jan 18 2025 11:30:43
Module end 'content'
Timing: Jan 18 2025 11:30:43
Script end

Main resources:

Total runtime1.4382 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0089 587.7109180.8359
Module start 'content' 0.00891.2811 768.5469673.8203
Module end 'content' 1.29000.1482 1,442.3672345.0625
Script end 1.4381  1,787.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.3174210.0002
Check MTime0.00190.1341210.0001
Mysql Total
Database connection0.00100.069510.0010
Mysqli_queries1.335192.83302110.0063
Looping result0.00250.17622090.0000
Template Total1.401697.520.7008
Template load0.00200.138520.0010
Template processing1.399697.315320.6998
Template load and register function0.00010.006910.0001
states
state_id_array0.00140.099310.0014
state_identifier_array0.00140.095320.0007
Override
Cache load0.00190.13241010.0000
Sytem overhead
Fetch class attribute can translate value0.00110.079640.0003
Fetch class attribute name0.00200.1390110.0002
XML
Image XML parsing0.00190.130640.0005
class_abstraction
Instantiating content class attribute0.00000.0022160.0000
General
dbfile0.00260.1782410.0001
String conversion0.00000.000530.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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/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: 37
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs