Forums / Setup & design / Implementing caching- cache-block questions

Implementing caching- cache-block questions

Author Message

arthur foelsche

Tuesday 13 May 2003 4:12:32 am

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',
'list',
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}
{/section}
</table>
{/let}

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:
http://red.eggplantmedia.com/~fluoride/ez/index.php

beware, the page loads slowly!

Paul Forsyth

Tuesday 13 May 2003 5:33:58 am

arthur,

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 :)

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:

http://ez.no/developer/ez_publish_3/contributions/binshellclearcachesh_fix_to_clear_cacheblocks

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...

paul

arthur foelsche

Tuesday 13 May 2003 8:25:47 am

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

arthur foelsche

Tuesday 13 May 2003 4:20:57 pm

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!

Paul Forsyth

Wednesday 14 May 2003 3:30:07 am

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 :)

Paul

Paul Forsyth

Wednesday 14 May 2003 3:31:40 am

Try this program on this site:

http://www.joedog.org/siege/index.shtml

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

Paul

eZ debug

Timing: Jan 18 2025 04:09:32
Script start
Timing: Jan 18 2025 04:09:32
Module start 'content'
Timing: Jan 18 2025 04:09:32
Module end 'content'
Timing: Jan 18 2025 04:09:32
Script end

Main resources:

Total runtime0.1458 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.0057 587.8438180.8125
Module start 'content' 0.00570.0042 768.656397.8203
Module end 'content' 0.00980.1359 866.4766529.3750
Script end 0.1458  1,395.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.3377200.0002
Check MTime0.00130.9100200.0001
Mysql Total
Database connection0.00120.833110.0012
Mysqli_queries0.106873.25781410.0008
Looping result0.00120.85081390.0000
Template Total0.135693.010.1356
Template load0.00080.569910.0008
Template processing0.134892.427110.1348
Override
Cache load0.00060.401810.0006
Sytem overhead
Fetch class attribute can translate value0.00080.547210.0008
XML
Image XML parsing0.00030.176910.0003
General
dbfile0.00140.9410200.0001
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