Disable caching on module/view level?

Author Message

Knut Urdalen

Sunday 04 November 2007 3:13:28 am

I've written some custom modules in my own extension which has a search form and a result when you call it. I set the state of the search form dynamically based on some input parameters from the query string (GET). The problem is that when I have enabled ViewCaching and TemplateCache (I'm not 100% sure what's the difference) it won't output the new template I've generated - it keep loading the previous template from the cache (the initial state of the form).

So the question is: Is it possible to have TemplateCache and ViewCaching enabled for the whole site, but filter out the dynamic parts and say: "Please do not cache these views"?

My typical production settings related to caching:

[ContentSettings]
ViewCaching=enabled
StaticCache=disabled

[DebugSettings]
DebugOutput=disabled
DebugRedirection=disabled

[TemplateSettings]
Debug=disabled
ShowXHTMLCode=disabled
ShowUsedTemplates=disabled
TemplateCompile=enabled
TemplateCache=enabled

André R.

Sunday 04 November 2007 6:45:10 am

ViewCache is cache for the content/view module, so has no effect on your custom module.
TemplateCache is the global setting for en/disabling cache-blocks, you can control your cache blocks from within your templates.

http://ez.no/doc/ez_publish/technical_manual/3_10/reference/template_functions/miscellaneous/cache_block

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Knut Urdalen

Monday 05 November 2007 5:42:34 am

Thanks for explaining the difference :)

I've tested a bit more now and enabling ViewCaching works fine. I use {cache-block} around the top menu and a site map at the bottom in pagelayout.tpl, while the {$module_result.content} do not use the cache-block mechanism.

However I have to set TemplateCache=disabled in order to get the result I want. My module script looks like this:

<?php
// 1. do stuff

// 2. setting some template variables
$tpl->setVariable('result', $result);
$tpl->setVariable('access_type', $GLOBALS['eZCurrentAccess']);

// 3. prepare result
$Result = array();
$Result['content'] = $tpl->fetch('design:mymodule/search_result.tpl');
?>

as described in this tutorial: http://ez.no/ezpublish/documentation/development/extensions/module/module_tutorial_part_1.

$result contains the correct new values, but those values is not set in $tpl->fetch() - the template remains in the previous state (when TemplateCache=enabled). Any ideas?

Knut Urdalen

Monday 05 November 2007 6:00:15 am

A related question to this topic is how can you include dynamic data from a custom fetch function inside a node template if you want to use ViewCaching in general, but some parts on some pages should not use it?

Use case: A content node includes some general meta data, but in addition you want to display some related content from an external data source that changes every minute.

Currently I use a node template with a custom fetch function - when ViewCaching=enabled the dynamic content remains in the view cache, while ViewCaching=disabled it's fetched again.

Any hints or tips?

Sujit Sth

Tuesday 04 January 2011 9:13:59 pm

Disable cache

Follow the following instruction.

1. Go to your template file:
eg:
E:\xampp\htdocs\ezpublish\settings\siteaccess\your_site\site.ini.append.php

2. Place the following code:

[DebugSettings]

DebugOutput=enabled

DebugRedirection=disabled

DebugToolbar=disabled

DebugByIP=disabled

DebugByUser=disabled

[TemplateSettings]

TemplateCompile=disabled

TemplateCache=disabled

DevelopmentMode=disabled

ShowUsedTemplates=enabled

Debug=disabled

ShowXHTMLCode=disabled

[ContentSettings]

ViewCaching=disabled

[DatabaseSettings]

SQLOutput=disabled

[DebugSettings]

DebugOutput=enabled

DebugRedirection=disabled

DebugToolbar=disabled

DebugByIP=disabled

DebugByUser=disabled

[TemplateSettings]

TemplateCompile=disabled

TemplateCache=disabled

DevelopmentMode=disabled

ShowUsedTemplates=enabled

Debug=disabled

ShowXHTMLCode=disabled

[ContentSettings]

ViewCaching=disabled

[DatabaseSettings]

SQLOutput=disabled

<span class="Apple-style-span" style="font-family: Arial, Helvetica, sans-serif; white-space: normal; font-size: 13px; " mce_fixed="1">Go and enjoy the code !!!!!!</span>

For detail follow the link below:

http://blog.developeronhire.com/tag/disble-cache/

Regards,

Sujeet

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.