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.