Forums / Developer / [solved] Cache block - Subtree expiry - error.log

[solved] Cache block - Subtree expiry - error.log

Author Message

Clemens T

Thursday 18 December 2008 4:04:40 am

Hello All,

In my pagelayout I have the following statement for a cache-block (at the absolute top of the file):

{def $current_node=fetch('content','node',hash('node_id',$module_result.content_info.node_id))}
{cache-block subtree_expiry=$uri_string keys=array($uri_string,$current_node.node_id)}

1) I'm using a 'current_node' to check in my pagelayout for certain values of the current_node (for example: show_in_menu, whether the page should be underline in the menu or not). Is that good practice, or should I avoid this at all costs?

2) the cache-block has a <b>subtree_expiry</b> with <b>$uri_string</b>, and the keys also related to that. This is to make sure that (for example) the menu doesn't look the same in all the pages (and also has to do with the logic, that is a bit different when loading a different node_id). Is this good practice?

Now, my <b>error.log</b> is full of:

Could not find path_string for 'subtree_expiry' node.
[ Dec 18 2008 02:01:25 ] [xx.xx.xx.xx] eZTemplateCacheFunction::subtreeExpiryCacheDir():

So this is probably related to that cache-block?

My settings (cache etc) - for a production environment (which also results in these errors):

[ContentSettings]
ViewCaching=enabled
PreViewCache=disabled

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

Next to this I also have a couple of the following errors in my error.log:

[ Dec 18 2008 XX:XX:XX ] [X.X.X.X] eZFileHandler::unlink:
Failed unlinking file var/siteaccess/cache/template-block/subtree/2/cache/2/7/4/2748722210.cache.gen

3) Is all of this related, and does anyone recognize the errors and know a (partial) improvement or solution?

Thanks for any input, it already cost me quite a lot of time.

Clemens

Ivo Lukac

Thursday 18 December 2008 5:09:29 am

Hello Clemens,

Your line:

{cache-block subtree_expiry=$uri_string keys=array($uri_string,$current_node.node_id)}

does not make sense.
With subtree_expiry you set in which part of tree published objects will trigger cache expiry.
Also $uri_string and $current_node.node_id carry same information so you don't need it both.
This will do want you want:

{cache-block keys=array($uri_string)}

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Clemens T

Thursday 18 December 2008 6:42:01 am

Thanks Ivo for paying attention to my problem.

The thing is that the menu items are editable, so when I change the title of menu item 1 to menu item 2, the pagelayout should be invalidated. This behaviour should be the same for submenu items.

Is this line then still sufficient?

{cache-block keys=array($uri_string)}

Ivo Lukac

Thursday 18 December 2008 7:30:23 am

Yes. If you don't place subtree_expiry that cache block will expire after publishing objects anywhere in the tree.
Here is more about this: http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_functions/miscellaneous/cache_block

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Clemens T

Friday 19 December 2008 4:17:33 am

Thanks, that at least saved the subtree_view errors. I'll make another post on the unlinking error.