CakePHP3-奇怪的缓存问题
我正在从事一个项目,该项目最初是由cakephp 3.0公共测试版启动的,后来被更新为当前的稳定版本。出于某种原因,每个请求都会被缓存约2分钟,即使是那些专门禁用缓存的请求。这使得开发变得绝对不可能,因为调试代码(var_dump等)在代码更改的情况下仍然存在 在MAMP3(PHP5.6)上本地运行 App.phpCakePHP3-奇怪的缓存问题,php,cakephp,caching,cakephp-3.0,Php,Cakephp,Caching,Cakephp 3.0,我正在从事一个项目,该项目最初是由cakephp 3.0公共测试版启动的,后来被更新为当前的稳定版本。出于某种原因,每个请求都会被缓存约2分钟,即使是那些专门禁用缓存的请求。这使得开发变得绝对不可能,因为调试代码(var_dump等)在代码更改的情况下仍然存在 在MAMP3(PHP5.6)上本地运行 App.php 'Cache' => [ 'default' => [ 'className' => 'File', 'path' =>
'Cache' => [
'default' => [
'className' => 'File',
'path' => CACHE
],
'weather' => [
'className' => 'File',
'duration' => '+6 hours',
'path' => CACHE,
],
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
'_cake_core_' => [
'className' => 'File',
'prefix' => '_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+2 seconds',
],
/**
* Configure the cache for model and datasource caches. This cache configuration
* is used to store schema descriptions, and table listings in connections.
*/
'_cake_model_' => [
'className' => 'File',
'prefix' => '_cake_model_',
'path' => CACHE . 'models/',
'serialize' => true,
'duration' => '+2 seconds',
],
],
env.php(即DOTENV)
BaseController.php(超类)
Cache::Enabled()
正在按预期输出false
HTTP响应具有以下标头:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json; charset=UTF-8
Date:Mon, 01 Jun 2015 19:18:39 GMT
Expires:Mon, 26 Jul 1997 05:00:00 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Mon, 01 Jun 2015 19:18:39 GMT
Pragma:no-cache
Server:Apache
Transfer-Encoding:chunked
我的tmp/cache/*/目录始终为空
尽管所有这些更改都需要两分钟才能在浏览器中反映出来
非常感谢您提供的任何帮助。听起来更像是一个非CakePHP问题,比如缓存代理,或者是操作码缓存,比如APC或Optimizer+。我相信您说的opcache是对的。禁用了它,它似乎又能正常工作了。谢谢
public function beforeFilter(Event $event){
parent::beforeFilter($event);
$this->response->disableCache();
Cache::disable();
}
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json; charset=UTF-8
Date:Mon, 01 Jun 2015 19:18:39 GMT
Expires:Mon, 26 Jul 1997 05:00:00 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Mon, 01 Jun 2015 19:18:39 GMT
Pragma:no-cache
Server:Apache
Transfer-Encoding:chunked