Codeigniter禁用缓存

kaa*_*rch 7 php caching codeigniter

我正在尝试学习Codeigniter并了解到目前为止的基础知识,但是当我尝试测试时,似乎缓存正在阻碍.通常,当我在localhost上测试时,我做了一个更改并立即在浏览器中看到它,但是使用Codeigniter,似乎我需要等待~1分钟才能在浏览器中看到更改.有没有办法普遍禁用Codeigniter缓存,以便在发生变化时立即发生?

Viv*_*vex 10

只需将此代码放在控制器的__construct函数中即可

$this->output->set_header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
$this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Run Code Online (Sandbox Code Playgroud)

  • 你的示例代码的第五行有一些问题,`$ this-> output-> set_header` (4认同)