On Thu, Apr 14, 2011 at 2:11 AM, cricket <[email protected]> wrote:

> On Wed, Apr 13, 2011 at 11:37 PM, Brian Sweeney <[email protected]>
> wrote:
>
>  > I have a view that's fairly computationally expensive (lots of
> table-formatted data).
> > To speed up the page load I'm trying to use view caching.
>
> Cached views bypass the controller[1], so if your content (the html)
> depends on state-sensitive data it may not be your answer. Like
> francky said, you probably could be using elements with caching
> disabled, or even given alternative cache options than the action
> itself has.
>

I think even though some of the content is state-sensitive the page could
still benefit from view caching. It does present some difficulties, though,
which is why I'm here.

But even if I take out the state-sensitive aspects of the page I'm still
running into user-specific inconsistencies in the cached view. The worst
example is if I access the page initially as an admin vs. normal user. The
cached page is completely broken in the latter case, but works fine in the
former.


>  > A problem which appears to be a bug to me.
>
> It's a bug in your view. To Cake and PHP, it's a gotcha.
>

Perhaps. I'd like to know more about the caching process, though, so I have
a better feel for what's possible and what's not. This seems like a bug to
me because the nocache content is being cached after the first iteration.
But I realize it could also just be a limitation of how the document is
parsed.


>  > which includes user authentication and user-specific inline content I'm
> getting
> > varied results.
>
> You can access the Session from an (uncached) element.
>

But can I access, for example, the authentication component? I pass along
the instantiation to the view (i.e. $this->set('Auth', $this->Auth)) so that
I can display some restricted content inline on the page.

Perhaps this is something I should be looking at admin routing for? I
haven't really looked into that functionality yet.


>  > I'm also hacking around the inability to use component-instantiated
> > components by echoing out some PHP code.
>
> Components are for Controllers and other Components, not Views. Use a
> Helper.
>

Sorry, I meant component-instantiated variables. Though, as I mentioned
above, I'm also doing some things with the auth component in the view.
Should I be accessing this information by another means?


>  > If anyone's interested in more details about what problems I'm having
> and
> > how I'm attempting to work around them I'd be more than happy to share a
> less
> > simplistic example.
>
> A more realistic example would help in coming up with a solution. You
> don't need to paste the entire view, just broad strokes or a snippet
> or two.
>

I'll be back later today with some more concrete examples. I'm going to hack
at it a little more this morning and see what comes of things.


> [1] But see here:
>
> http://nuts-and-bolts-of-cakephp.com/2011/02/05/make-your-cakephp-app-ridiculously-faster-with-view-caching/
>

One of my first find when I started doing this ;)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to