diff options
author | Derek Jones <derek.jones@ellislab.com> | 2010-03-20 01:57:33 +0100 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2010-03-20 01:57:33 +0100 |
commit | d99e603f47e10adc015d4b804352db71f0563062 (patch) | |
tree | 988f403d6347367ff7f1023bfa40138b595f2b14 /system/core | |
parent | 5ed19b477072edb77aa4337be71551fae5d9736d (diff) |
reordered logic in _display_cache() to eliminate a call to is_really_writable() on each page request unless it is_really_needed()
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/Output.php | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/system/core/Output.php b/system/core/Output.php index 0dcf2e46f..ac4129405 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -377,12 +377,7 @@ class CI_Output { function _display_cache(&$CFG, &$URI) { $cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path'); - - if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path)) - { - return FALSE; - } - + // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url'). $CFG->item('index_page'). @@ -410,7 +405,7 @@ class CI_Output { flock($fp, LOCK_UN); fclose($fp); - + // Strip out the embedded timestamp if ( ! preg_match("/(\d+TS--->)/", $cache, $match)) { @@ -419,10 +414,13 @@ class CI_Output { // Has the file expired? If so we'll delete it. if (time() >= trim(str_replace('TS--->', '', $match['1']))) - { - @unlink($filepath); - log_message('debug', "Cache file has expired. File deleted"); - return FALSE; + { + if (is_really_writable($cache_path)) + { + @unlink($filepath); + log_message('debug', "Cache file has expired. File deleted"); + return FALSE; + } } // Display the cache |