This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Setup & design » Implementing caching- cache-block...

Implementing caching- cache-block questions

Implementing caching- cache-block questions

Tuesday 13 May 2003 1:12:32 pm - 5 replies

I have some questions about implementing caching. I've got my site fairly much done, but am noticing that I really need to figure out ways to improve the speed of the front page loads, as this page has to dig through all the content in the database in order to construct itself. I looked at the manual description of the cache-block function, but haven't figured out if i'm implementing it correctly, as i haven't seen any speed improvements (yes, i have turned on view caching in site.ini.php)

here's the code i'm using in the template:
20 most recent stories: <br>
{let test=fetch( 'content',
hash(parent_node_id, 158, class_filter_type, "include", class_filter_array, array(2), "sort_by", array("modified", false()), "depth", 0))
<table> {cache-block keys=$test}
{section name=Child loop=$test max=20}
<tr><td valign="top"><font size=-1>{$Child:item.data_map.article_date.data_int|l10n(date)}</td>
<td><font size=-1><a href={concat("/content/view/full/",$Child:item.node_id)|ezurl}>{attribute_view_gui attribute=$Child:item.data_map.pagetitle}</a>
<i>{attribute_view_gui attribute=$Child:item.data_map.article_location}</i></td></tr>{/cache-block}

have i used cache-block correctly?

I guess the other question i have is how to move this into a {$module_result.content} output. The way the site is configured is to have a front page which has a listing of all the recent articles (and navigation to older pages) and link through to specific sections and articles which display by region. Basically a newswire which links through to a categorized news wire. I'm using two different templates to do this- one for the front page and one to display either the region or the individual article. Is there a way to specify a different format for {$module_result.content} for different templates, but using the same module?

you can see what i'm doing here:

beware, the page loads slowly!

Tuesday 13 May 2003 2:33:58 pm


move the cache block to before the {let test=fetch... this will create a php cache of the results of the database calls - rather speeds things up happy.gif Emoticon

also, try this type of cache-block instruction. instead of caching just a single variation of your page it will work if you have dynamic pages that depend on changes between the node.

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

finally, copy this contribution to your local ez files:

this will allow you to clear cached files between tests... many a time ive wondered whats going on with cache off and finding cache being created...


Modified on Tuesday 13 May 2003 2:34:27 pm by Paul Forsyth

Tuesday 13 May 2003 5:25:47 pm

wow- that made a huge different in page load times! Thanks! Its great to have people helping out in this fourm!

Wednesday 14 May 2003 1:20:57 am

thanks for your help. I now understand what you were saying about wanting to use a different kind of caching for dynamic content- here you mentioned this call:

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

should i replace stories and used.node with my particulars? or is this the format that i should use?

thanks again!

Wednesday 14 May 2003 12:30:07 pm

You should replace 'stories' with your own variables when you use the cache-block. Remember, this is an id so its not a good idea to use the same id more than once otherwise the id may index the same cached file...

Dont replace the $DesignKeys as that is an ez variable used when cache is on.

However, saying that, the particular example i gave works well since its allows your variable to be indexed. For example, if you have dynamic content for each node it may be seen as {stories, 1}, {stories, 2}, etc, and there will be a cached page for each.

One upshot of this is that more disk space will be used for cache (for each node) but you get better performance.

We are still experimenting with this so hopefully will learn the ins and outs with time happy.gif Emoticon


Wednesday 14 May 2003 12:31:40 pm

Try this program on this site:

It allows you artificially stress your site and will give speeds on access. Ez use it i believe.



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from