[email protected]
[Top] [All Lists]

nocache breaks when used in loop

Subject: nocache breaks when used in loop
From: BrianS
Date: Wed, 13 Apr 2011 13:37:22 -0700 PDT
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. Works great, except when I try to "nocache" content that's inside a loop (foreach in this instance). When cake encounters this section of content it correctly treats it as dynamic the first time around, but subsequent instances are then rendered as if they were cached content. So the first instance is correct, then every following instance is parsed into static content.

A simple example. Create a controller with an empty action. In the view for that action place the following:
for ($i = 0; $i < 10; $i++) {
        echo "
Turn on caching. After you load that view, open up the cache file and you will see that the first time the loop is run the PHP code is maintained. Every time after that, though, the PHP is replaced with the actual output and surrounded by the nocache tags.

Anyone seen this before or have any thoughts on what's going wrong?

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
<Prev in Thread] Current Thread [Next in Thread>