如何在特定功能中禁用代码点火器缓存.如果代码点火器被启用


how to disable codeigniter cache in specific function. if codeigniter is enable

我的代码点火器缓存已启用,但我想禁用搜索控制器的缓存。请帮助我如何禁用任何特定功能的代码点火器缓存。

提前谢谢。

如果您读取文档,您可以看到,如果您想在方法中缓存一些视图,您需要放置

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);
    }
}
<?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');
        }
    }

有关更多详细信息,请查看链接

https://www.blazingcoders.com/how-to-disable-browser-cache-easily-for-particular-individual-and-separate-function-and-controller-in-codeigniter