Codeigniter禁用缓存 [英] Codeigniter Disable Cache

查看:91
本文介绍了Codeigniter禁用缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我正在尝试学习Codeigniter并了解基本知识,但是在尝试进行测试时,似乎高速缓存已成问题.通常,当我在localhost上进行测试时,我进行了更改并立即可以在浏览器中看到它,但是使用Codeigniter似乎我需要等待〜1分钟才能在浏览器中看到更改.有没有一种方法可以普遍禁用Codeigniter缓存,以便在开发更改时立即发生?

I'm trying to learn Codeigniter and understand the basics so far, but as I try to test, it seems the cache is getting in the way. Normally when I test on localhost I make a change and instantly can see it in browser, but with Codeigniter it seems I have to wait ~1 minute for changes to be seen in browser. Is there a way to universally disable the Codeigniter cache so when developing changes happen immediately?

推荐答案

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

Just put this code in the __construct function of controller

$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");

这篇关于Codeigniter禁用缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆