Thursday 16 March 2006 8:26:55 am
Hi, I want to enable cache to speed up site access. I'm quite a newbie whent it comes to enabling caching, but this is what I've done in override/site.ini.append.php:
[TemplateSettings]
TemplateCache=enabled
TemplateCompile=enabled
TemplateCompression=enabled TemplateOptimization=enabled
[RegionalSettings] TranslationCache=enabled
[ContentSettings]
ViewCaching=enabled PreViewCache=disabled Now I have some problems with accessing variables like $node.node_id, etc. When I enable caching with cache blocks, I get all kind of weird problems like images not being updated in a gallery before the cache expires. I read a forum post about using $module_result.content instead, but it's only available in pagelayout.tpl? I couldn't access this variable in any of my override templates. Anyway, here is an example of a override template where I'm using a cache block.
{* beginning of template *}
{set-block scope=root variable=cache_ttl}0{/set-block}
{cache-block expiry=20 keys=$uri_string}
{* some code for a image gallery *}
{foreach $galleries as $m}
{if or(eq($m.node_id, $node.node_id), eq($node.parent_node_id, $m.node_id))}
<p class="redcolor"><a class="redcolor" href={$m.url_alias|ezurl}>{$m.name|wash|upcase}</a></p>
{else}
<p><a href={$m.url_alias|ezurl}>{$m.name|wash|upcase}</a></p>
{/if}
{/foreach}
{/cache-block}
Now the big question here is if I'm doing this the right way. I've had a hard time gathering some scattered information about how to implement cache in eZ. I guess I just can't use cache-blocks everywhere, and have to test and try if it works in different settings?
|