Cache-Block Usage

Author Message

Alex Jones

Wednesday 03 September 2003 7:13:19 am

I am implementing cache-blocks in my templates, but am unsure as the best practice to follow. Specifically, I have a product form that is the foundation for hundreds of nodes in the system. I would like to cache each page , but when I place a cache-block around the entire template (which overrides full.tpl) it caches the first item viewed and uses that information when displaying any product. So, if I look at product ABC first, it is cached causing page XYZ to display all of ABC's information. I set up the cache with a key of the node ID as I thought this would guarantee a unique cache key, but apparently not.

Here is an example of the cache-block code I am using:
{cache-block keys=$node_id}
<h1>{attribute_view_gui attribute=$content_version.data_map.page_name}</h1>
{/cache-block}

Is this a case where I need to use an array for the keys? Paul mentioned this idea in http://ez.no/developer/ez_publish_3/forum/setup_design/implementing_caching_cacheblock_questions but I am not sure if this is solving the question I face.

Also, if I do not provide an expiry, does the cache automatically expire at a given time?

What am I doing wrong, and what is the best way to ensure pages are cached and as efficient as possible?

I'm using 3.1.

Thanks in advance!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Wednesday 03 September 2003 8:41:26 am

Alex,

I get mixed results from using cache blocks. Sometimes they work fantastically well and other times they don't quite...

The cache should expire when the article is updated in the admin, or by the time you specify.

Have you tried an array based cached block, like:

{cache-block keys=array('page_name',
$DesignKeys:used.node)}

Your description shoulds like it should cache each node. Thats fine, there only the initial hit of processing each node. But once done it should be v fast.

As long as your id is unique it should work...

Paul

Alex Jones

Wednesday 03 September 2003 8:58:35 am

Hrrrm, I'll try the array to see if that works. :) I'm still confused as to why setting it with the Node ID didn't work. Hopefully the array will help.

Thanks Paul!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Paul Forsyth

Wednesday 03 September 2003 9:14:03 am

It might be something silly like the $node_id not being defined in your current name space...

paul

Alex Jones

Wednesday 03 September 2003 9:21:40 am

Yeah, that would be silly....and me thinks the exact reason I ran into problems. :)

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

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

Main resources:

Total runtime0.8200 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.9375152.6094
Module start 'layout' 0.00730.0039 741.546939.4141
Module start 'content' 0.01130.8075 780.9609555.6875
Module end 'content' 0.81880.0012 1,336.648416.1875
Script end 0.8199  1,352.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4404160.0002
Check MTime0.00150.1800160.0001
Mysql Total
Database connection0.00130.154710.0013
Mysqli_queries0.750391.4994630.0119
Looping result0.00070.0809610.0000
Template Total0.779095.020.3895
Template load0.00280.339320.0014
Template processing0.776294.665620.3881
Template load and register function0.00010.013910.0001
states
state_id_array0.00080.102310.0008
state_identifier_array0.00110.134120.0005
Override
Cache load0.00230.2832370.0001
Sytem overhead
Fetch class attribute can translate value0.00140.171620.0007
Fetch class attribute name0.00180.224860.0003
XML
Image XML parsing0.00080.093020.0004
class_abstraction
Instantiating content class attribute0.00000.002380.0000
General
dbfile0.00080.0950160.0000
String conversion0.00000.001640.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs