【问题标题】:why codeigniter creates a cache file with name controller+function?为什么codeigniter会创建一个名称为controller+function的缓存文件?
【发布时间】:2016-04-25 22:29:39
【问题描述】:

我在 codeigniter 框架上建立了一个网站,我注意到 root 上有一些文件夹,名称为 controller+function(例如:welcome+index),使用 PHPStorm。这些文件夹具有页面的缓存文件。

问题是我没有在代码中添加任何缓存语句,即使我删除了它们,它们也会自动重新创建。

有谁知道为什么要重新创建这些文件以及如何禁用此功能?

【问题讨论】:

  • 这里的问题是因为phpstorm它兑现了文件,

标签: php codeigniter caching directory


【解决方案1】:
$db['default']['cache_on'] = TRUE;

将此设为假 在您的配置 database.php 上

【讨论】:

    【解决方案2】:

    _output() 方法在任何控制器(having _output() 方法)调用时写入缓存文件(如果您启用了缓存)。

    您可以通过此代码禁用缓存:

        /*cache control*/
        $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"); 
    

    只需将上面的代码放在控制器的__construct函数中即可。

    【讨论】:

    • 不幸的是,它没有用。文件夹仍然创建
    • 请检查$this->output->cache();进入控制器。如果存在,请对其进行评论并检查。
    猜你喜欢
    • 2019-03-23
    • 2013-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-04
    • 1970-01-01
    • 2022-11-07
    • 1970-01-01
    相关资源
    最近更新 更多