/:
이는 캐시 된 파일이 아닌 디스플레이 제어기/액션 코드를 처리하기위한 검사
if ($EXT->_call_hook('cache_override') === FALSE)
{
if ($OUT->_display_cache($CFG, $URI) == TRUE)
{
exit;
}
}
.
표시되기 전에 캐시 된 파일의 만료 확인 방법을 Output 클래스에서 읽을 수도 있습니다.
function _display_cache(&$CFG, &$URI)
{
$cache_path = ($CFG->item('cache_path') == '') ? APPPATH.'cache/' : $CFG->item('cache_path');
// Build the file path. The file name is an MD5 hash of the full URI
$uri = $CFG->item('base_url').
$CFG->item('index_page').
$URI->uri_string;
$filepath = $cache_path.md5($uri);
if (! @file_exists($filepath))
{
return FALSE;
}
if (! $fp = @fopen($filepath, FOPEN_READ))
{
return FALSE;
}
flock($fp, LOCK_SH);
$cache = '';
if (filesize($filepath) > 0)
{
$cache = fread($fp, filesize($filepath));
}
flock($fp, LOCK_UN);
fclose($fp);
// Strip out the embedded timestamp
if (! preg_match("/(\d+TS--->)/", $cache, $match))
{
return FALSE;
}
// Has the file expired? If so we'll delete it.
if (time() >= trim(str_replace('TS--->', '', $match['1'])))
{
if (is_really_writable($cache_path))
{
@unlink($filepath);
log_message('debug', "Cache file has expired. File deleted");
return FALSE;
}
}
// Display the cache
$this->_display(str_replace($match['0'], '', $cache));
log_message('debug', "Cache file is current. Sending it to browser.");
return TRUE;
}
템플릿 시스템 대신, 아마도 출력을 캡처하고 저장하기 위해'ob_start'와 친구들을 사용할 것입니다. 캐싱 작업을하는 가장 좋은 방법은 조건부 HTTP 헤더 인 If : 및 If-Modified-Since :를 사용하는 것입니다. CodeIgniter가 실제로 그렇게하는지 또는 미리 구성된 타임 아웃에만 의존하는지는 모르지만. – mario