2011-09-14 48 views
6

中的清除页面缓存如何。总是我的页面的一部分缓存,并且不会通过browser.when中的Ctrl+F5删除。当我在其视图中更改了名称页面时。 !?我使用CodeIgniter的CodeIgniter

如何清除CodeIgniter中的页面缓存?

回答

-6

它可能在session。尝试删除您的cookies。

+0

我删除cookies在chrome浏览器,但不能确定。 –

+0

当我改变它的视图名称页面的工作。 !? –

+0

其保存的服务器端,如下所述:http://codeigniter.com/user_guide/general/caching.html – nonchip

5
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); 
} 
3
public function clear_path_cache($uri) 
{ 
    $CI =& get_instance(); 
$path = $CI->config->item('cache_path'); 

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