summaryrefslogtreecommitdiff
path: root/feed.php
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2009-11-15 15:24:50 +0100
committerMichael Klier <chi@chimeric.de>2009-11-15 15:24:50 +0100
commit0d67055cfede37804a2ad231c821d87ea6bc4e3e (patch)
treebd60a247ced9e68816ef3e3e37f66e0e5466a7a6 /feed.php
parente259aa7939e5d3cd704351d4d53d1d1497217a11 (diff)
downloadrpg-0d67055cfede37804a2ad231c821d87ea6bc4e3e.tar.gz
rpg-0d67055cfede37804a2ad231c821d87ea6bc4e3e.tar.bz2
make feed use the cache class - fixes FS#1676
darcs-hash:20091115142450-23886-297f1373aeafdbdb5d33097b220d29798f663a2d.gz
Diffstat (limited to 'feed.php')
-rw-r--r--feed.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/feed.php b/feed.php
index 26af0096f..a98c8b159 100644
--- a/feed.php
+++ b/feed.php
@@ -25,11 +25,13 @@ $opt = rss_parseOptions();
// the feed is dynamic - we need a cache for each combo
// (but most people just use the default feed so it's still effective)
$cache = getCacheName(join('',array_values($opt)).$_SERVER['REMOTE_USER'],'.feed');
-$cmod = @filemtime($cache); // 0 if not exists
-if ($cmod && (@filemtime(DOKU_CONF.'local.php')>$cmod || @filemtime(DOKU_CONF.'dokuwiki.php')>$cmod)) {
- // ignore cache if feed prefs may have changed
- $cmod = 0;
-}
+$key = join('', array_values($opt)) . $_SERVER['REMOTE_USER'];
+$cache = new cache($key, '.feed');
+
+// prepare cache depends
+$depends['files'] = getConfigFiles('main');
+$depends['age'] = $conf['rss_update'];
+$depends['purge'] = ($_REQUEST['purge']) ? true : false;
// check cacheage and deliver if nothing has changed since last
// time or the update interval has not passed, also handles conditional requests
@@ -37,10 +39,10 @@ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Type: application/xml; charset=utf-8');
header('X-Robots-Tag: noindex');
-if($cmod && (($cmod+$conf['rss_update']>time()) || ($cmod>@filemtime($conf['changelog'])))){
- http_conditionalRequest($cmod);
- if($conf['allowdebug']) header("X-CacheUsed: $cache");
- print io_readFile($cache);
+if($cache->useCache($depends)) {
+ http_conditionalRequest($cache->_time);
+ if($conf['allowdebug']) header("X-CacheUsed: $cache->cache");
+ print $cache->retrieveCache();
exit;
} else {
http_conditionalRequest(time());
@@ -80,7 +82,7 @@ rss_buildItems($rss, $data, $opt);
$feed = $rss->createFeed($opt['feed_type'],'utf-8');
// save cachefile
-io_saveFile($cache,$feed);
+$cache->storeCache($feed);
// finally deliver
print $feed;