Codeigniter Disable Cache

后端 未结 4 1414
遥遥无期
遥遥无期 2020-12-18 00:30

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

相关标签:
4条回答
  • 2020-12-18 01:00

    Just delete all the cached items in the application/cache folder:

    http://ellislab.com/codeigniter/user-guide/general/caching.html
    
    0 讨论(0)
  • 2020-12-18 01:02

    IF you enabled the cache, you need to disable it (comment out the cache). Otherwise it may be your browser caching, you could force a SHIFT-F5 (in most browsers).

    The cache will only work if you have it so defined in your controller etc; not randomly.

    0 讨论(0)
  • 2020-12-18 01:02
    <?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 Detail Explanation check the link

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

    0 讨论(0)
  • 2020-12-18 01:05

    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");
    
    0 讨论(0)
提交回复
热议问题