如何在CodeIgniter中清除页面缓存

mf98qq94  于 2022-12-07  发布在  其他
关注(0)|答案(4)|浏览(173)

我使用CodeIgniter。总是我的网页的一部分是缓存,不删除的Ctrl+F5在浏览器中。当我改变名称页在视图中工作!!!?
如何在CodeIgniter中清除页面缓存?

u0sqgete

u0sqgete1#

您需要手动删除application/cache文件夹中的缓存项目。
https://www.codeigniter.com/user_guide/general/caching.html

6kkfgxo0

6kkfgxo02#

function delete_cache($uri_string=null)
{
    $CI =& get_instance();
    $path = $CI->config->item('cache_path');
    $path = rtrim($path, DIRECTORY_SEPARATOR);

    $cache_path = ($path == '') ? APPPATH.'cache/' : $path;

    $uri =  $CI->config->item('base_url').
            $CI->config->item('index_page').
            $uri_string;

    $cache_path .= md5($uri);

    return unlink($cache_path);
}
sy5wg1nm

sy5wg1nm3#

public function clear_path_cache($uri)
{
    $CI =& get_instance();
    $path = $CI->config->item('cache_path');
    //path of cache directory
    $cache_path = ($path == '') ? APPPATH.'cache/' : $path;

    $uri =  $CI->config->item('base_url').
    $CI->config->item('index_page').
    $uri;
    $cache_path .= md5($uri);

    return @unlink($cache_path);
}



/**
 * Clears all cache from the cache directory
 */
public function clear_all_cache()
{
    $CI =& get_instance();
    $path = $CI->config->item('cache_path');

    $cache_path = ($path == '') ? APPPATH.'cache/' : $path;

    $handle = opendir($cache_path);
    while (($file = readdir($handle))!== FALSE) 
    {
        //Leave the directory protection alone
        if ($file != '.htaccess' && $file != 'index.html')
        {
           @unlink($cache_path.'/'.$file);
        }
    }
    closedir($handle);       
}
xiozqbni

xiozqbni4#

它可能在session中。请尝试删除您的Cookie。

相关问题