Monday, February 1, 2010

Re: disabling cache when a user is logged

On Jan 31, 11:32 am, Lorenzo Bettini <bett...@dsi.unifi.it> wrote:
> Hi
>
> in my AppController I've enabled cache for view and index actions and
> they work fine.
>
> Now, I'd like to disable cache when a user is logged, since in that case
> additional information are shown that must not be cached.
>
> Thus I added the method
>
>         function beforeRender() {
>                 if ($this->is_logged_user()) {
>                         // disable cache when the user is logged, since some information
>                         // must NOT be cached, e.g., private papers
>                         $this->cacheAction = array();
>                 }
>         }
>
> where is_logged_user is a function that checks whether a user is logged.
>
> This works in the sense that no cache is used when a user is browsing
> the site.  However, if the user visits an action page which has already
> been cached then he will get the cached page, which I want to avoid as
> well...  is there a way to avoid this?
>
> I've also tried with $this->disableCache() but that does not work.
>
> The only solution I see is to clear the cache, but I'd want to avoid that...

Why not change the cached view folder (in the bootstrap) based on the
presence or not of a session cookie.

OR directly use http://github.com/mcurry/html_cache if appropriate

hth,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: