這裏有一些代碼來覆蓋Codeigniter的Output類,它似乎對我很有用。
從Output.php創建文件的應用程序/核心/ MY_Output.php,複製在_write_cache()和_display_cache()函數和更新它是這樣的:
class MY_Output extends CI_Output {
function __construct() {
parent::__construct();
}
function _write_cache($output) {
....
$uri = $CI->config->item('base_url').
$CI->config->item('index_page').
$CI->uri->uri_string();
// append querystring
$qs = (empty($_SERVER['QUERY_STRING'])) ? '' : '?'.$_SERVER['QUERY_STRING'];
$uri .= $qs;
// append querystring
....
}
function _display_cache(&$CFG, &$URI)
....
$uri = $CI->config->item('base_url').
$CI->config->item('index_page').
$URI->uri_string;
// append querystring
$qs = (empty($_SERVER['QUERY_STRING'])) ? '' : '?'.$_SERVER['QUERY_STRING'];
$uri .= $qs;
// append querystring
....
}
可能重複[Codeigniter頁面緩存與GET參數](http://stackoverflow.com/questions/14516670/codeigniter-page-cache-with-get-parameter) – Seb33300 2017-01-28 17:41:06