我正在使用CakePHP 2.6
当我重定向回请求所在的同一视图时,我遇到了问题。视图似乎已缓存,因此在请求期间进行的任何更改都不会显示,直到页面再次刷新。
这意味着:
为什么会这样?
我检查过的事情:
Configure::write('debug', 2);
Configure::write('Session', array(
'defaults' => 'php'
));
代表性的例子:
//Inside ListingsController...
$this->Listing->id = $id;
if ($this->Listing->save($listing)) {
$this->Flash->success(__('"%s" is now active.', $listing['Listing']['title']));
} else {
$this->Flash->error(__('Problem activating'));
}
//this is the original view...
$this->redirect( array('controller'=>'listings', 'action'=>'mylistings') );
答案 0 :(得分:1)
我有完全相同的问题。你找到了这一切的原因吗?当我试图解决这个问题时,我在回复标题中看到了这个
Age 0
Connection keep-alive
Date Tue, 21 Apr 2015 08:47:21 GMT
Server ATS/3.2.4
所有304 Not Modified Status
的文件都有Apache Traffic Server(ATS)(来自我的局域网),这让我觉得它是导致所有这些行为的文件;我按照here的解释强制进行非缓存,因此我没有更多问题。
答案 1 :(得分:0)
尝试将其重定向到引用者
$this->Listing->id = $id;
if ($this->Listing->save($listing)) {
$this->Flash->success(__('"%s" is now active.', $listing['Listing']['title']));
// Redirect the referer
$this->redirect(
$this->referer()
);
} else {
$this->Flash->error(__('Problem activating'));
}
谢谢..!