简体   繁体   English

如何在特定功能中禁用 codeigniter 缓存。 如果启用了 codeigniter

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

My codeigniter cache is enable, but i want to disable the cache for my search controller.我的 codeigniter 缓存已启用,但我想禁用我的搜索控制器的缓存。 please help me that how to disable the codeigniter cache for any specific function.请帮助我了解如何禁用任何特定功能的 codeigniter 缓存。

Thanks in advance.提前致谢。

if you reed the documentation, you can see that if you want to cache some view in method you need to put如果你阅读文档,你会看到如果你想在方法中缓存一些视图,你需要把

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

    }

For more detail check the link有关更多详细信息,请查看链接

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM