Home » Php » php – Disabling cache on CakePHP 2.4.4

php – Disabling cache on CakePHP 2.4.4

Posted by: admin July 12, 2020 Leave a comment

Questions:

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';
}
How to&Answers:

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

Answer:

in app/Config/core.php

enable Configure::write('Cache.disable', true);

worked for me. after this no models and persistent cache generating.

Answer:

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.

Answer:

It turns out it was an issue with MAMP / PHP.
MAMP was set to PHP 5.5.3. After downgrading to version 5.2.17 the caching problem has been solved.