Forums / Developer / [solved] Viewcache issue

[solved] Viewcache issue

Author Message

Tristan Rivoallan

Friday 22 July 2005 2:37:59 am

Hi,

i'm having trouble setting up view cache for a private area of the website i'm currently developping.

If i enable viewcaching, once user A logs in and cache for his views are generated, every other that logs after user A will see user A views. Cache is only created once.

I tried to surround user related parts of content with

{cache-block keys=array($user_uid, $request_uri)}
  Private content
{/cache-block}

this didn't change anything.

I'm using a custom user login handler (don't know if it is of any interest).

any pointers ?

thx in advance

Łukasz Serwatka

Friday 22 July 2005 4:08:02 am

Hi Tristan,

Look at this article
http://ez.no/products/ez_publish_cms/documentation/incoming/how_to_set_cache_expire_time_or_disable_cache_in_template

and

http://ez.no/products/ez_publish_cms/documentation/development/kernel/cache_block_optimization

Makre sure that $user_uid has correct value.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Tristan Rivoallan

Friday 22 July 2005 5:54:43 am

Thanx for answering.
I already read (and read again) these articles.

> Look at this article
> http://ez.no/products/ez_publish_...re_time_or_disable_cache_in_template

If I set cache_ttl to 0, it works but then there's no more caching so that is pretty useless ;)

> http://ez.no/products/ez_publish_...ment/kernel/cache_block_optimization

> Make sure that $user_uid has correct value.

I thought for a long time that this was the problem. But now that I am sure that the value is correct, the problem persists :(
I set this value with

{ezhttp('id_partenaire', 'session')}

. Can this be a problem ?

Using cache blocks looks pretty straightforward as long as you are sure of key uniqueness. I'm now 100% sure that keys are unique, but i'm still having trouble.

I'll continue looking for a solution

Łukasz Serwatka

Friday 22 July 2005 6:36:10 am

Have you tried without cache-blocks?

Try also with this code:

{def $current_user=fetch( 'user', 'current_user' )}

{cache-block keys=$current_user.contentobject_id}
    Private content
{/cache-block}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Konrad Mazurkiewicz

Friday 22 July 2005 7:46:37 am

Hi,
if your cache-block is in class view template only way is to disable cache for whole template.

Look at thread where it is clarified:
http://ez.no/community/forum/developer/viewcaching_and_cache_block_when_to_use

Konrad

Tristan Rivoallan

Monday 25 July 2005 3:04:44 am

WOUHOU! it works.

thanx for the clarification, for me cache-blocks and view cache where the same thing.

so the trick was to disable view caching and enabling cache blocks.

i'm now looking for a way to pregenerate cache after every change of data in the db. See you in another thread...