diff options
| author | 2014-10-28 23:52:46 +0100 | |
|---|---|---|
| committer | 2014-10-28 23:52:46 +0100 | |
| commit | 00127f07c5fc784130d658e3f26519b0279fc6b8 (patch) | |
| tree | 218c057df7edb710e062e4605779840cded156f3 /lib/SimplePie/SimplePie.php | |
| parent | 4cbd7e0583709912d790ed04a72b75d79da31b73 (diff) | |
SimplePie: cache feeds with errors
Before the cache system was not used for feeds with errors, which was
problematic especially if several users have this feed.
Furthermore, there was no protection against repetitive refresh.
Bonus: slightly better performance by avoiding some superfluous
file_exists().
Warning: needs a bit of testing
https://github.com/marienfressinaud/FreshRSS/issues/681
Diffstat (limited to 'lib/SimplePie/SimplePie.php')
| -rw-r--r-- | lib/SimplePie/SimplePie.php | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index 06c100f59..84001dd9a 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -1455,7 +1455,11 @@ class SimplePie { // Load the Cache $this->data = $cache->load(); - if (!empty($this->data)) + if ($cache->mtime() + $this->cache_duration > time()) { //FreshRSS + $this->raw_data = false; + return true; // If the cache is still valid, just return true + } + elseif (!empty($this->data)) { // If the cache is for an outdated build of SimplePie if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) @@ -1487,7 +1491,7 @@ class SimplePie } } // Check if the cache has been updated - elseif ($cache->mtime() + $this->cache_duration < time()) + else //if ($cache->mtime() + $this->cache_duration < time()) //FreshRSS removed { // If we have last-modified and/or etag set //if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) //FreshRSS removed @@ -1516,6 +1520,7 @@ class SimplePie } else { + $cache->touch(); //FreshRSS $this->error = $file->error; //FreshRSS return !empty($this->data); //FreshRSS //unset($file); //FreshRSS removed @@ -1533,17 +1538,18 @@ class SimplePie } } } - // If the cache is still valid, just return true - else - { - $this->raw_data = false; - return true; - } + //// If the cache is still valid, just return true + //else //FreshRSS removed + //{ + // $this->raw_data = false; + // return true; + //} } // If the cache is empty, delete it else { - $cache->unlink(); + //$cache->unlink(); //FreshRSS removed + $cache->touch(); //FreshRSS $this->data = array(); } } |
