version".
(see dispatcher::cached() and ViewHelper#__writeFile()).
Regarding to the docs its not recommended to use the callbacks (
http://book.cakephp.org/view/1380/Caching-in-the-Controller ) .
I would probably try to separate the "display" and "save" part into 2
actions or put the form into an
element and cache that element manually, not via cacheAction.
e.g. in your view script
if($this->data || !($content = Cache::read('big_form', 'persistent'))) {
$content = $this->element('big_form');
if (!$this->data) {
Cache::write('big_form', $content, 'persistent');
}
}
echo $content;
Am 30.10.2011 19:26, schrieb BlenderStyle:
> I have setup the index and edit actions to be cached in my
> PostsController as follows:
>
> var $cacheAction = array(
> 'index' => array('callbacks' => true, 'duration' => '7 days'),
> 'edit' => array('callbacks' => true, 'duration' => '7 days'),
> );
>
> Everything is cached as expected, but the edit form doesn't submit.
> This is expected as well, if you think about it, but is there anyway
> to bypass caching when a user submits a form?
>
> I set callbacks to true to allow AuthComponent to do its magic, so if
> I could put some code in beforeFilter(), it's executed dynamically
> (not cached). I have tried each of the following in beforeFilter(),
> one by one, but none of them did the trick:
>
> if(!empty($this->data)) clearCache();
> if(!empty($this->data)) Configure::write('Cache.check', false);
> if(!empty($this->data)) $this->cacheAction = false;
>
> To avoid the "why would you even want to do that" argument I see in
> other forums, I'll explain a little further. My edit action is fairly
> intensive since it's such a long form with a lot of "stuff" in it and
> caching definitely improves the performance. To avoid writing extra
> code, the edit action displays the form as well as saves it.
>
--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment