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.

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

Main resources:

Total runtime0.0178 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.0065 588.0469152.6406
Module start 'layout' 0.00660.0038 740.687539.4766
Module start 'content' 0.01030.0055 780.164193.4922
Module end 'content' 0.01580.0019 873.656338.3047
Script end 0.0178  911.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002413.6421140.0002
Check MTime0.00116.3568140.0001
Mysql Total
Database connection0.00169.110410.0016
Mysqli_queries0.002011.250330.0007
Looping result0.00000.073710.0000
Template Total0.00158.610.0015
Template load0.00084.715310.0008
Template processing0.00073.884510.0007
Override
Cache load0.00063.343210.0006
General
dbfile0.00042.219080.0000
String conversion0.00000.038940.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