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

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 16:20:43
Script start
Timing: Jan 18 2025 16:20:43
Module start 'layout'
Timing: Jan 18 2025 16:20:43
Module start 'content'
Timing: Jan 18 2025 16:20:43
Module end 'content'
Timing: Jan 18 2025 16:20:43
Script end

Main resources:

Total runtime0.0172 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.9141152.6250
Module start 'layout' 0.00730.0023 740.539139.4453
Module start 'content' 0.00960.0053 779.9844101.3203
Module end 'content' 0.01490.0022 881.304746.3047
Script end 0.0172  927.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.004325.1840140.0003
Check MTime0.002313.2595140.0002
Mysql Total
Database connection0.00148.320310.0014
Mysqli_queries0.002112.077030.0007
Looping result0.00000.074910.0000
Template Total0.00179.810.0017
Template load0.00095.495110.0009
Template processing0.00074.308510.0007
Override
Cache load0.00063.669410.0006
General
dbfile0.00031.649680.0000
String conversion0.00000.040240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs