我的codeigniter缓存已启用,但我想为我的搜索控制器禁用缓存。请帮我解决如何禁用任何特定功能的codeigniter缓存。
提前致谢。
答案 0 :(得分:0)
如果您使用文档,您可以看到如果要在方法中缓存某些视图,则需要将其放入
class Somthing extends CI_Controller{
function one(){//with cache
$data['variabe'] = $this->model->get_somthing();
$this->load->view('view', $data);
$this->output->cache($seconds);
}
fucntion two(){//without cache
$data['variabe'] = $this->model->get_somthing();
$this->load->view('view', $data);
}
}
答案 1 :(得分:0)
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class MY_Cacheoff extends CI_Cacheoff {
/**
* author: https://www.blazingcoders.com
*/
function disable_cache() {
$this->set_header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
$this->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$this->set_header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0');
$this->set_header('Cache-Control: post-check=0, pre-check=0', FALSE);
$this->set_header('Pragma: no-cache');
}
}
有关更多详细信息,请检查链接