Forums / Developer / User parameters cause cache trouble [solved]

User parameters cause cache trouble [solved]

Author Message

Tobias Vogel

Wednesday 31 October 2007 10:07:09 am

Hi all,

I made a generic newsticker-template (included in other node/view/full templates), that changes it's content depending on user parameters, e.g.:

.../index.php/siteaccess/news/overview/(mode)/archive/(year)/2005

When I tested it on a live installation (ezp 3.10) with template and view caching enabled, the page only gets generated once, using the parameters passed with that request. Any further requests with different custom parameters set (e.g. /(year)/2006) just return the first (wrong) version from the cache.

According to the following documentation page (last paragraph), the cache system should automatically be aware of user parameters and keep different versions of the page:
http://ez.no/ezpublish/documentation/customization/custom_design/user_specified_parameters

This obvoiusly doesn't work. I already tried to set the TTL to 0 and/or use custom cache blocks, but none of the measures had any affect. Ezpublish will always serve the version of the first request.

Do you have any additional hints or ideas, what is going wrong here?

Tobias Vogel

Friday 02 November 2007 3:14:27 am

If I set

TemplateCache=disabled

the problem is gone. Anyway that doesn't seem to be the right solution to me.

I tried custom cache-blocks in the include template:

{set-block scope=global variable=cache_ttl}0{/set-block}
{cache-block keys=array($node,$view_parameters)}
...
[template code]
...
{/cache-block}

These settings don't have any effect wherever I place them, even in the pagelyout.

Sebastiaan van der Vliet

Friday 02 November 2007 9:30:18 am

Hi Tobias, did you also try putting {cache-block expiry=0}include file{/cache-block}?

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

André R.

Friday 02 November 2007 10:14:05 am

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

Is for view cache ( aka content view cache, as in cache for the content/view module view), so has no effect on cache blocks.

As for setting expiry=0, this is what happens(from the doc):

A value of zero will produce a cache block that will never expire.

the reason it doesn't work is that the keys parameter only supports 1 level deep arrays.
It will not understand the $node or $view_parameters objects!

You can use $module_result.uri ( url + view params + view param values) if this is in a pagelayout:

{cache-block keys=$module_result.uri}
...
[template code]
...
{/cache-block}

You need to know what params are going to be used if this is in a node template:

{def $user_id = first_set($view_parameters.id, '')}
{cache-block keys=array($node.node_id, $user_id, $view_parameters.offset)}
...
[template code]
...
{/cache-block}

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

Tobias Vogel

Monday 05 November 2007 6:11:42 am

Wow, thanks for your explanation, helped me a lot further and I also found the reason for some strange behaviour:

Somewhere in the middle of the pagelayout there was another cache-definition:

{cache-block keys=array($uri_string, $basket_is_empty, $user_hash)}

IMHO I read somewhere, that ezpublish can't keep track of children in a nested cache-block structure, so this artifact cache-block additionally interfered with my tests.

eZ debug

Timing: Jan 18 2025 14:53:28
Script start
Timing: Jan 18 2025 14:53:28
Module start 'content'
Timing: Jan 18 2025 14:53:28
Module end 'content'
Timing: Jan 18 2025 14:53:28
Script end

Main resources:

Total runtime0.1582 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.8438180.8125
Module start 'content' 0.00600.0067 768.656398.0547
Module end 'content' 0.01270.1454 866.7109527.1250
Script end 0.1581  1,393.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.2968200.0002
Check MTime0.00150.9585200.0001
Mysql Total
Database connection0.00080.505810.0008
Mysqli_queries0.110169.60461410.0008
Looping result0.00130.83001390.0000
Template Total0.145091.610.1450
Template load0.00100.649910.0010
Template processing0.143990.973310.1439
Override
Cache load0.00070.471610.0007
Sytem overhead
Fetch class attribute can translate value0.00080.477310.0008
XML
Image XML parsing0.00020.142910.0002
General
dbfile0.00603.8224200.0003
String conversion0.00000.003930.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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