summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-01-18 01:49:48 +0100
committerAndrey Andreev <narf@bofh.bg>2013-01-18 01:49:48 +0100
commitb1d216ea969619befe2ddec9ffd6497465fcb333 (patch)
tree843874778dc60864e533eb2b41785abc15412427 /system
parente9eb64f863ffeacd2986eb75e0aaaeb95d12a122 (diff)
parent3e6b58215a78f63f43a62c584a1386bda2a1f3e1 (diff)
Merge pull request #2151 from cryode/feature/output-cache-improvements
Add headers to Output class cache files.
Diffstat (limited to 'system')
-rw-r--r--system/core/Output.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 27e711783..e6c48b5dd 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -543,10 +543,16 @@ class CI_Output {
}
$expire = time() + ($this->cache_expiration * 60);
+
+ // Put together our serialized info.
+ $cache_info = serialize(array(
+ 'expire' => $expire,
+ 'headers' => $this->headers
+ ));
if (flock($fp, LOCK_EX))
{
- fwrite($fp, $expire.'TS--->'.$output);
+ fwrite($fp, $cache_info.'ENDCI--->'.$output);
flock($fp, LOCK_UN);
}
else
@@ -595,14 +601,16 @@ class CI_Output {
flock($fp, LOCK_UN);
fclose($fp);
- // Strip out the embedded timestamp
- if ( ! preg_match('/^(\d+)TS--->/', $cache, $match))
+ // Look for embedded serialized file info.
+ if ( ! preg_match('/^(.*)ENDCI--->/', $cache, $match))
{
return FALSE;
}
+
+ $cache_info = unserialize($match[1]);
+ $expire = $cache_info['expire'];
$last_modified = filemtime($cache_path);
- $expire = $match[1];
// Has the file expired?
if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path))
@@ -617,6 +625,12 @@ class CI_Output {
// Or else send the HTTP cache control headers.
$this->set_cache_header($last_modified, $expire);
}
+
+ // Add headers from cache file.
+ foreach ($cache_info['headers'] as $header)
+ {
+ $this->set_header($header[0], $header[1]);
+ }
// Display the cache
$this->_display(substr($cache, strlen($match[0])));