Skip to content
Snippets Groups Projects
Commit 7131b668 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

caching for feeds

This patch adds caching for XML/ATOM feeds. This is most useful for the
default feed (linked from the footer and HTML meta header) as this is
usually the most used one.

The cache is invalidated if a change was made (by checking the the
filemtime of the changelog). A 5 minute settling time is used to avoid
invalidating the cache too often when the wiki changes rapidly.

darcs-hash:20050806155857-7ad00-5b9cb05b42d67c3f23f0358676735038b9f59664.gz
parent f4b3aca3
No related branches found
No related tags found
No related merge requests found
......@@ -13,14 +13,7 @@
require_once(DOKU_INC.'inc/feedcreator.class.php');
require_once(DOKU_INC.'inc/auth.php');
//set auth header for login FIXME: is this used anymore???
if($_REQUEST['login'] && !isset($_SERVER['PHP_AUTH_USER'])){
header('WWW-Authenticate: Basic realm="'.$conf['title'].'"');
header('HTTP/1.0 401 Unauthorized');
auth_logoff();
}
//close sesseion
//close session
session_write_close();
......@@ -44,13 +37,20 @@
$type = 'RSS1.0';
}
//some defaults for the feed
$CACHEGROUP = 'feed';
$conf['typography'] = false;
$conf['canonical'] = true;
$parser['toc'] = false;
// 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($num.$type.$mode.$ns.$ltype.$_SERVER['REMOTE_USER'],'.feed');
// check cacheage and deliver if nothing has changed since last
// time (with 5 minutes settletime)
$cmod = @filemtime($cache); // 0 if not exists
if($cmod && ($cmod+(5*60) >= @filemtime($conf['changelog']))){
header('Content-Type: application/xml; charset=utf-8');
print io_readFile($cache);
exit;
}
# $rss = new UniversalFeedCreator();
// create new feed
$rss = new DokuWikiFeedCreator();
$rss->title = $conf['title'];
$rss->link = DOKU_URL;
......@@ -69,8 +69,14 @@
rssRecentChanges($rss,$num,$ltype);
}
$feed = $rss->createFeed($type,'utf-8');
// save cachefile
io_saveFile($cache,$feed);
// finally deliver
header('Content-Type: application/xml; charset=utf-8');
print $rss->createFeed($type,'utf-8');
print $feed;
// ---------------------------------------------------------------- //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment