The Feed Evolves Again

I finally decided to heed the wise suggestions of John and Dave and save on some bandwidth by removing the comment count from my RSS Feed. Despite it’s usefulness the addition forced readers to download a new version of the feed every time a single number was incremented. Since I began including full entries at the same time I was unnecessarily hemorrhaging bandwidth.

So how to provide this functionality without requiring a fresh download every time someone posted a new comment? I created a PHP script that generates a PNG (I love WebMonkey) that alerts you to the total number of comments and new comments since your last visit/read. The script receives one variable: the never-changing, unique id for each entry. It then checks the mt_comment table for the number of comments made on that particular entry. That part was easy.

Determining how many comments were made since the site or a particular article in the feed was last viewed was more complicated. When working with browsers you can store temporary information on a viewer’s machine in the form of cookies—like the date and time of a their last visit. As far as I know it is impossible to set cookies in a RSS aggregator so visits need to be tracked server-side. I set up a simple MySQL table that records the remote ip in one column and the date and time in a second MySQL TIMESTAMP column. Then I ran a second query on the mt_comment table, this time only looking for posts made after the last visit.

Caveats? The current two column last visit table solution falls apart when checking more than one article for new comments. The first article you view updates your last visit which makes it impossible to grab the newer comments since your true last visit. (I do have a solution for this problem but haven’t had time to implement it yet.)

I hope to have some source up here for you guys to pick apart by the end of the week.

Previous
Live Wire on Threadless
Next
Threadmore
Author
Shaun Inman
Posted
March 24th, 2004 at 11:33 am
Categories
The Site
PHP
Comments
003 (Now closed)

003 Comments

001

I just recently removed comment numbers from my feeds as well for a similar reason. (I was more concerned with users getting annoyed at repeatedly having to mark a thread as read than with bandwidth since my site is fairly low-traffic.) The PHP-generated PNG, however, is a handy solution - I may play with something similar when I have time. Thanks! :D

The new comments since last visit feature is probably overkill for my setup, but I’d be interested in seeing the code for it anyway.

Author
Ste Grainer
Posted
Mar 24th, 2004 10:04 am
002

Why not have two different feeds? I liked the *Title (x) * one.

Author
Danny Cohen
Posted
Mar 27th, 2004 11:35 am
003

Just curious, I use the Firefox RSS reader extension. Any clue why I could drag and drop the link to your feed from this post, but not from the link at page bottom? Thanks .

Author
Hasan
Posted
Apr 5th, 2004 7:31 pm