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.

eZ debug

Timing: Jan 18 2025 02:09:31
Script start
Timing: Jan 18 2025 02:09:31
Module start 'layout'
Timing: Jan 18 2025 02:09:31
Module start 'content'
Timing: Jan 18 2025 02:09:32
Module end 'content'
Timing: Jan 18 2025 02:09:32
Script end

Main resources:

Total runtime1.0856 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 588.0391152.6406
Module start 'layout' 0.00580.0026 740.679739.4766
Module start 'content' 0.00831.0759 780.1563620.7109
Module end 'content' 1.08420.0014 1,400.867216.1406
Script end 1.0856  1,417.0078 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3016160.0002
Check MTime0.00130.1238160.0001
Mysql Total
Database connection0.00100.089410.0010
Mysqli_queries0.998591.9764660.0151
Looping result0.00070.0647640.0000
Template Total1.049696.720.5248
Template load0.00200.184320.0010
Template processing1.047696.500520.5238
Template load and register function0.00010.012910.0001
states
state_id_array0.00130.118810.0013
state_identifier_array0.00160.152020.0008
Override
Cache load0.00190.1718750.0000
Sytem overhead
Fetch class attribute can translate value0.00080.070730.0003
Fetch class attribute name0.00140.127080.0002
XML
Image XML parsing0.00320.292930.0011
class_abstraction
Instantiating content class attribute0.00000.0019100.0000
General
dbfile0.00330.3017290.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs