Disabling cache on CakePHP 2.4.4
Solution 1
Applications/MAMP/bin/php/php5.5.3/conf/php.ini and may be in /Applications/MAMP/conf/php5.5.3/php.ini
comment out the line in this block! [OPcache]
spent three days on this
Solution 2
in app/Config/core.php
enable Configure::write('Cache.disable', true);
worked for me. after this no models
and persistent
cache generating.
Solution 3
See http://book.cakephp.org/2.0/en/controllers/request-response.html#CakeResponse::disableCache
So in your controller:
$this->response->disableCache();
either globally via beforeRender callback, or specifically per action.
Note that for IE8 comp. regarding this you might need to add an additional header as shown here.
Moritz
Updated on July 02, 2022Comments
-
Moritz almost 2 years
I've read a bunch of Stackoverflow questions with the same goal: disabling cache in the CakePHP framework. However, none of these solutions has worked for me unfortunately.
My core.php now has these values, but the caching of controllers and views is still unbearably long for development:
Configure::write('debug', 2); Configure::write('Cache.disable', true); $duration = '+1 day'; if (Configure::read('debug') > 0) { $duration = '+1 seconds'; }
-
mark over 10 yearsThat's not how it is done in CakePHP. Use the response class.
-
-
Moritz over 10 yearsI've added this to my AppControler.php, but it is still caching. public function beforeFilter() { $this->response->disableCache(); }
-
xtraorange over 10 yearsYou win the internet. I could kiss you right on the mouth.