Forums / Setup & design / Cache-block subtree expiration - how deep does it check?
Piotrek Karaś
Monday 09 April 2007 5:38:33 am
Hi,
I have now spent over a week trying to figure out subtree_expiry parameter of cache-block function. Unfortunately, no effects...I've gone through every piece of information of this forum and documentation that seemed to be relevant, tried every combination that seemed logical... Basically - it does not work and took me to draw one conclusion - subtree_expiry only works, when a child node directly one level below the block is expired, two or more do not matter... But then what would be the purpose of it?
The task seems simple. I have the following structure:
+ vehicles ++ cars +++ bmw +++ peugeot ++ motorcycles +++ honda
When in 'vehicles' node, I fetch all the sub-nodes to output a list of vehicle groups (lev2) and their brands (lev3). How do I force the cache to be expired in case something on level3 changes?
Thanks for any suggestions.
-- Company: mediaSELF Sp. z o.o., http://www.mediaself.pl eZ references: http://ez.no/partners/worldwide_partners/mediaself eZ certified developer: http://ez.no/certification/verify/272585 eZ blog: http://ez.ryba.eu
Kristof Coomans
Monday 09 April 2007 11:03:30 pm
Hi Piotr
Can you show us the cache-block you used? Thanks.
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
Monday 09 April 2007 11:50:36 pm
Hello Kristof,
I can show you what my best guesses were, but it would be difficult to remember all the combinations I have gone through, it took hours... :) Here we go:
design:full/my_vehicles_class.tpl (level1)
{* a *}{cache-block keys=$node.node_id subtree_expiry=$node.path_identification_string} {* b *}{cache-block subtree_expiry=$node.path_identification_string} {* fetch('content','list/tree', ...) *} {* display level2 and level3 elements *} {/cache-block}
I tried two scenarios as well, with level2 and level3 elemenents being published via administration interface and self-prepared 'add group/add brand' content action forms.
Tuesday 10 April 2007 3:38:13 am
Give this a try:
subtree_expiry=$node.url_alias|remove(0,1)
Tuesday 10 April 2007 4:44:54 am
Nothing changes, except for the fact that there's a debug error:
Error: eZTemplateCacheFunction::subtreeExpiryCacheDir() Could not find path_string for 'subtree_expiry' node.
What exactly would be the purpose of it? Should I expect any special characters in the url_alias attribute that may affect the function? In that case, wouldn't it be better to trim its value instead? Otherwise, what would be the point? Just curious :)
Tuesday 10 April 2007 5:57:12 am
Apparently I encountered certain issues with cache-block before, and the code above made it work in those cases. I inspected the PHP code now and what I did was indeed not needed since slashes are trimmed in the PHP template function code to.
Do you have DelayedCacheBlockCleanup=enabled in one of your site.ini overrides? If yes then remove it or use the subtreeexpirycleanup cronjob. Have you enabled view caching? Then you need to disable it for your specific template. Put this at the first line of the template:
{set-block scope=root variable=cache_ttl}0{/set-block}
.
Tuesday 10 April 2007 6:39:05 am
That's right, now I remember some former posts concerned with subree_expiry syntax and the slashes. I think I have even tried concatenating the path and the slash... but it didn't work either as far as I remember... :)
I'll let know as soon as I check your latest suggestions. Thanks.
Wednesday 11 April 2007 2:53:23 pm
Yes! That's it. I added:
then:
{cache-block subtree_expiry=$node.path_identification_string}
and it begun to work as expected! It's just 10 minutes of experimenting, but it seems like good direction.
Thanks for your help, Kristof!