cache-block around $module_result.content

Author Message

Michael Zeidler

Monday 13 September 2004 2:53:19 am

Hi,

Please explain me, why its not a good idea to add a cache-block around {$module_result.content}, as I have read somewhere here in this forum. Unfortunately i cant find this appropriate topic anymore.
I cant see any disadvantages using cache-block this way:

{cache-block expiry=0 keys=array($uri_string,$current_user.role_id_list|implode(','))}
  {$module_result.content}
{/cache-block}

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

Edward Eliot

Monday 13 September 2004 4:09:53 am

I guess it depends on how much control you want over the caching. If you only need to cache certain parts of the page then this implementation isn't going to be much good. If you are happy caching the whole page then it's fine.

Michael Zeidler

Monday 13 September 2004 4:30:17 am

What parts on the website you dont want to be cached? IMHO I would prefer caching rather than any php and database query execution, cause outputting a text file is faster than that. Ok you might distinguish parts which only executes php functions like echo() and on the other hand php functions accessing backends, like DB, LDAP, or processing transformations of XML.
So {$module_result.content} involves at least database queries, isnt that a reason to cache it.

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

Paul Forsyth

Monday 13 September 2004 5:01:29 am

I think you are missing what eZ publish is about. {$module_result.content} returns the results from your current view, but that view may itself be made up of many other templates, some of which may be dynamic and should not be cached.

Sometimes your headers,footers, menu etc are in that view, and not the main pagelayout. It all depends on your design and what you need. eZ publish gives you this flexiblity.

You could put everything in pagelayout, this could be what your design requires. I know from my own experience that it varies.

If your content rarely changes then the cache block around the content would help.

paul

Michael Zeidler

Tuesday 14 September 2004 1:15:02 am

Yes of course {$module_result.content} returns the current view which is generated by the requested module to do so. Generally database queries are involved with that, dynamic elements are excluded. So for me a good reason to cache it.

> but that view may itself be made up of many other templates,
> some of which may be dynamic and should not be cached.

Do you mean templates which includes for instance the print out of the current date or things like that? Yes, this wouldnt make any sense to cache it. So it would be good to put these things into the pagelayout.tpl and not to use any cache-block for it. But of course it depends on the flavor where in the design to do the printing out of dynamic contents, as you already have said.
But from the point of view that the content ({$module_result.content}) is altered only by an publishing event the cache-block solution would fit in this case.

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

Ole Morten Halvorsen

Tuesday 14 September 2004 1:57:07 am

Cupic,

The content module already has caching (called ViewCache), so putting a cache-block around would cache an already cached page. Also, if you put cache-blocks around $module_result.content you will mess up modules which needs to be dynamic like /user/login. The login template will not be able to display warnings if the user types wrong password for example.

In conclusion, you should not put cache-blocks around $module_result.content (you will experience weird behaviour) and you dont need to as the content module has ViewCache.

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Michael Zeidler

Tuesday 14 September 2004 6:40:04 am

Ok, thanks for the precious info. But as u might have seen I want to provoke that the cache-block wont be expired, because every two hours the cache will be cleared totally. Is the behavior of the view cache the same? See this posting http://ez.no/community/forum/general/how_to_switch_off_clear_cache_interval.
Some infos to ViewCache http://ez.no/community/forum/developer/viewcaching_and_cache_block_when_to_use

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

Michael Zeidler

Tuesday 14 September 2004 7:27:13 am

another example where the cache-block around $module_result.content fails ist the search. the search shouldnt be cached ;).

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

Ole Morten Halvorsen

Friday 17 September 2004 2:45:06 am

Cupic,

If you set expiry=0 the cache-block should never be expired unless something is published. If it doesn't then please file a bug report. If you don't want the cache-block to expire on publish use ignore_content_expiry.

Read more about cache-blocks here:
http://ez.no/ez_publish/documentation/development/kernel/cache_block_optimization

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Michael Zeidler

Friday 17 September 2004 5:19:06 am

Well, yes of course expiry=0 works very well. But the main goal is to do a work around the clear cache interval, which is set to two hours. Unfortunately there is no configuration variable to alter this value, it seems to be hard coded in the eztemplate engine(3.4.1). This is the reason why i want the content to be cached eternaly unless a publish action was triggered. Whats the reason for clearing the cache every two hours?
Please take a look on this: http://ez.no/community/forum/general/how_to_switch_off_clear_cache_interval

-------------------------------------------------------------------------------------------
join #ezpublish on irc.freenode.org

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 19 2025 04:19:53
Script start
Timing: Jan 19 2025 04:19:53
Module start 'layout'
Timing: Jan 19 2025 04:19:53
Module start 'content'
Timing: Jan 19 2025 04:19:54
Module end 'content'
Timing: Jan 19 2025 04:19:54
Script end

Main resources:

Total runtime1.5562 sec
Peak memory usage4,096.0000 KB
Database Queries82

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0075 589.2813152.6406
Module start 'layout' 0.00750.0038 741.921939.4609
Module start 'content' 0.01121.5437 781.3828694.3125
Module end 'content' 1.55490.0012 1,475.695324.1406
Script end 1.5561  1,499.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2132160.0002
Check MTime0.00130.0840160.0001
Mysql Total
Database connection0.00120.075310.0012
Mysqli_queries1.480795.1472820.0181
Looping result0.00070.0433800.0000
Template Total1.519797.720.7599
Template load0.00200.130420.0010
Template processing1.517797.526420.7588
Template load and register function0.00010.005910.0001
states
state_id_array0.00090.056410.0009
state_identifier_array0.00120.075820.0006
Override
Cache load0.00180.1177500.0000
Sytem overhead
Fetch class attribute can translate value0.00040.027340.0001
Fetch class attribute name0.00140.0898110.0001
XML
Image XML parsing0.00200.130840.0005
class_abstraction
Instantiating content class attribute0.00000.0020160.0000
General
dbfile0.00360.2325160.0002
String conversion0.00000.000740.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 40
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs