So I’ve updated the RSS feeds somewhat, as well as moving to a newer version of the backend software, so now it should be the case that the web server sends 304′s for the RSS feeds if nothing’s changed in the database. I’ve been doing gzipping of the content all along, but it seems most aggregators don’t support compressed HTTP streams (why would someone write their own HTTP client code these days ?!??). Now that NetNewsWire does though, people should find that helpful if they’re using NNW. Also imported my own aggregator list to a blogroll on the right of my main blog page. I’ll try to write an applescript to automate updating things when I subscribe/unsubscribe, but see below for why I might not do that — of course there’s no way to have NNW automatically call my script to say “By the way, subscriptions just changed”… I should probably also include a link to the OPML for those sources as well…

Hi Craig :)
I wondered about that 304 stuff; how did you do it? Does the app has to send an If-Modified-Since or do you somehow track the IPs and access times of your visitors? (I’m just thinking about hacking on KNewsTicker a bit — when SA 2.60 is finally out that is :o)
// Handle Conditional GET
// Get the time of the most recent article
$sql = "SELECT max(post_date) FROM $tableposts";
$maxdate = $wpdb->get_var($sql);
$unixtime = strtotime($maxdate);
// format timestamp for Last-Modified header
$clast = gmdate("D, d M Y H:i:s GMT",$unixtime);
$cetag = md5($last);
$slast = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
$setag = $_SERVER['HTTP_IF_NONE_MATCH'];
// send it in a Last-Modified header
header("Last-Modified: " . $clast, true);
header("Etag: " . $cetag, true);
// compare it to aggregator's If-Modified-Since and If-None-Match headers
// if they match, send a 304 and die
// This logic says that if only one header is provided, just use that one,
// but if both headers exist, they *both* must match up with the locally
// generated values.
//if (($slast?($slast == $clast):true) && ($setag?($setag == $cetag):true)){
if (($slast && $setag)?(($slast == $clast) && ($setag == $cetag)):(($slast == $clast) || ($setag == $cetag))) {
header("HTTP/1.1 304 Not Modified");
echo "rnrn";
exit;
}
Craig, if you want to save people and yourself a little bandwidth then might I politely suggest you ‘lite’ your feed from 25 posts to say 5-10?
Also did you know that the site is sending every no-cache header in the book? (This appears to stop IE & Mozilla and Opera ever getting a 304, as they never send the hash on the repeat request..
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Feel free to completely ignore me though :D
Chris, I’ve added an optional GET parameter “n” which can be used to ask for however many posts you want, eg
http://www.hughes-family.org/craig/b2/b2rss2.php?n=5
The caching headers might as well tell things to cache for an hour, since
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>1</sy:updateFrequency>
anyway. I’ll fix that as soon as I:
Thanks for pointing those out though — they should really be fixed.
Cool :) I;ll use this and save you a little bandwidth and make my updates a little faster. http://www.hughes-family.org/craig/b2/b2rss2.php?n=4
Setting it to 2 get the whole bunch in a single packet.