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.