Forums / Setup & design / {node_view_gui...} and View Caching

{node_view_gui...} and View Caching

Author Message

Nabil Alimi

Wednesday 01 November 2006 2:01:49 am

Hi,

How does view caching actually works ?

By using the node_view_gui operator with a custom view, is it used by default ?

Or should it be enabled in some way ?

Thanks !

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Kristian Hole

Wednesday 01 November 2006 9:26:14 am

A new chapter in the documentation which describes the viewcaching is actually available today!

http://ez.no/doc/ez_publish/technical_manual/3_8/features/view_caching

Enjoy :-)

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Nabil Alimi

Thursday 02 November 2006 5:43:37 am

Thanks Kristian,

Well looks like that there is no view caching while using {node_view_gui}.

Wouldn't it be a nice feature ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Kristian Hole

Thursday 02 November 2006 9:08:52 am

I don't know exactly how you would like that to work. Currently it works like this:

If you use {node_view_gui} in some of the node/view/*.tpl and overrides loaded by the content/view module, the {node_view_gui} will be cached by the view-caching. This is because the whole view is cached.

If you are using {node_view_gui} in the pagelayout or included templates, you should add a cacheblock around the code that is fetching/generation information from the database. I typically use cache-blocks for menus and similar elements in the pagelayout.

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

Was this understandable?

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Nabil Alimi

Thursday 02 November 2006 9:33:21 am

Yes that's how i'm actually processing.

But like this - provided you want to fine-tune the way you use cache-blocks with subtree_expiry - there's no equivalent to the smart view-cache clear feature that clears dependent nodes' view-cache and so on... (Dependent nodes = object-related ones for example).

This leads to less accurate cache-block handling...

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Kristian Hole

Thursday 02 November 2006 10:32:20 am

Yes, you are right. The all of the cache-blocks are automatically invalidated upon content-publish. You can however restrict it with the subtree_expiry and the ignore_content_expiry parameters. But it is as you say, less flexible than the smart-view-cache-system.

Do you have any good ideas on how to implement something similar for the cache-blocks?

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Nabil Alimi

Thursday 02 November 2006 11:45:58 am

Well, the only work-around I found fo far is to add the $node.object.modified time of the related object to the keys of the cache-block.
Like this, once the related object is modified, the cache-block expires and a new one is built. It works fine so far for most cases.
But if the related-object as itself related-objects, and that the node_view_gui displays or has any relation with those re-related-objects (wow), it might not work as we expect.

The topic remains open. :-)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Xavier Dutoit

Friday 03 November 2006 7:56:30 am

Salut Nabil,

Could you share with us the code you use ?

Not sure I understand how to use the date modified as a key.

X+

http://www.sydesy.com

Kristian Hole

Friday 03 November 2006 10:09:07 am

@Xavier:

Nabil means that he is doing something like this:

{cache-block keys=array( .... , $node.object.modified)}

@Nabil:

I see your point. It would be useful if the cache-blocks supported this somehow. Currently I do not have any good ideas for how this can be implemented. Anybody have any good ideas?

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Nabil Alimi

Tuesday 07 November 2006 1:31:48 am

Hi Xavier,

Kristian is right, that's how i'm proceeding.

Something nice would be to have a new dependent_nodes param to the cache-block operator which will work with an hash to support depth.

{cache-block ... dependent_nodes=hash( '234' , 2 , '350' , 4 )}

So if any node 2 levels below or upper node 234 is modified, the cache-block will expire.

Maybe it isn't a good idea at all though. :-)

And, I don't know if this can be easily made or not. :-)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Kristian Hole

Tuesday 07 November 2006 4:04:47 pm

Nabil:

So basically, what you want to be able to do is some thing like this:

{cache-block subtree_expiry=array('products/','company/about/','/forum)}
...
{/cache-block}

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute