且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何避免浏览器缓存使用Codeigniter

更新时间:2022-04-09 23:32:08

您可以向客户端发送适当的标头以禁用缓存:

You can send proper headers to the client to disable the cache:

....
$this->output->set_header("HTTP/1.0 200 OK");
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
$this->load->view('index', $data);

注意:输出类自动初始化

Note: Output class is initialized automatically