Forums / General / ViewCaching

ViewCaching

Author Message

Andrew Kelly

Monday 12 December 2005 6:57:12 am

Hi all,
I'm having a bit of a problem getting my brain around ViewCaching, wonder if anybody can help me out.

If I turn off my view caching, my server load starts climbing into ugly ranges and performace degrades rapidly. So obviously, we want to have ViewCaching enabled. The problem is that in my pagelayout.tpl, I have some code at the bottom the left column which displays the content editor and time of last modification for the content being shown in the "main view", and when I have ViewCaching enabled this code gets broken. The editor is blank, and the last modified falls back to 01/01/1970.

How do I keep ViewCaching enabled to keep my performance up, but still have the Editor/Modified code remain functional?

Help?

Andy

Mark Marsiglio

Monday 12 December 2005 7:14:13 am

Andrew,

The variables in pagelayout with viewcaching enabled are a little different than other view modes/templates.

Take a look at http://ez.no/doc/ez_publish/technical_manual/3_6/templates/the_pagelayout/variables_in_pagelayout

This has some details. I think if you use a variable based on $DesignKeys or $module_result, you should be OK.

Also, make sure that those lines of code are excluded from any cache blocks.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Andrew Kelly

Tuesday 13 December 2005 1:13:31 am

Thanks, Mark,

tip much appreciated.

Andy

Andrew Kelly

Thursday 15 December 2005 1:29:47 am

Right,
problem 1 solved, problem 2 appears.

ViewCaching is kicking the stuffing out of my left-hand navigation. I have primary and secondary
navigation in a banner, and levels 3-6 in a left-hand menu. Functionally, the menu is fine and does everything it's supposed to but for 1 small detail. The active menu item is designed to have a section-specific background color, and with ViewCaching turned on these highlighted elements slowly start disappearing until the feature no longer appears at all.

Is there any way at all to hide things from the caching mechanism? Can I say "View Caching yes, but not right here"?

Andy

Paul Forsyth

Thursday 15 December 2005 3:34:58 am

You could try turning off view caching in that template and then use cache blocks. That might work.

So put:

{set-block scope=global variable=cache_ttl}0{/set-block}

at the top.

But use {cache-block} to wrap everything else apart from your dynamic bit.

Another method which isnt as useful but might work for you is to put a timeout in the cache-block:

{set-block scope=global variable=cache_ttl}60{/set-block}

Which will expire every minute. Not sure if this helps though.

Paul

Andrew Kelly

Thursday 15 December 2005 4:14:01 am

Paul,

> Thursday 15 December 2005 12:34:58 pm
> You could try turning off view caching in that template and then use cache blocks. That might work.

Yes, that's exactly the lever I'm looking for. In my current (very limited) understanding of eZp, ViewCaching is a global setting which is either enabled or disabled in site.ini(.append.php)
If there is a way to exclude blocks of code from this caching it's still beyond my ken.

Is this how it's done?

> So put:
> {set-block scope=global variable=cache_ttl}0{/set-block}
> at the top.
>
> But use {cache-block} to wrap everything else apart from your dynamic bit.

I don't think I'm following, could you please repeat that in another example?

The stuff I'd like to exclude from ViewCaching is in a template of its own, included in
pagelayout.tpl.
{include uri="design:leftnavi.tpl"}

Thanks a ton,

Andy

Paul Forsyth

Thursday 15 December 2005 4:22:28 am

Yip thats right, so in your template leftnavi.tpl put:

{set-block scope=global variable=cache_ttl}0{/set-block}

at the very top as the first line. this will disable caching for that template while retaining view caching everywhere else.

Some more info:

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_functions/miscellaneous/cache_block
http://ez.no/community/forum/developer/view_cache_trouble/

Paul

Andrew Kelly

Thursday 15 December 2005 4:40:07 am

Outstanding!
Thank you very much, Paul.

Andy