Rules for Creating an RSS Feed
Thursday, July 17th, 2008Most of us don’t have to worry about creating an RSS feed for our sites - the CMS tool will do that automatically. But there are times when you are creating a custom application - when you have to create an RSS feed yourself. Creating it is easy - they don’t call it Really Simple Syndication for nothing. But there are a few rules(or rather, guidelines) that are ignored by most - make sure you follow them.
I am by no means an expert on this format - but I have created RSS feeds and have worked on applications to parse it. So I have seen my share of bad implementations.
Use RSS rather than Atom
I prefer using RSS as opposed to the Atom format. But Atom is now supported on almost all feed readers - so this preference may change. But for now, I like RSS better than Atom.
Last-Modified
Make sure your feed has the last modified header. This will prevent unnecessary downloading of the feed if there are no new articles. It saves both the site’s and the user’s bandwidth.
This is extremely easy in PHP…
$last_edited = '2008-07-17 01:02:03'; // This should be the time of the latest post.
header("Last-Modified: " . date('r',strtotime($last_edited)));
10 Posts
Make sure you provide a limited number of posts in the feed - the perfect number, in my opinion, is 10. It can increase or decrease a bit - its no big deal. If your posting frequency is high, the number should increase. And if the frequency is low, the number of items in the feed can go down.
But make sure that you are not including all the posts from the beginning of time until now. This is a big waste of bandwidth. Unfortunately, many have adopted this method. For example, take this feed - Cat and Girl Comic feed.
The other extream is just as bad - providing just the latest item in the feed. If the author writes two posts in quick succession, the viewers may not get an article. An example for this in the subnormality comic.
Validate it
XML is not as forgiving as HTML - so make sure you validate your feed before releasing it upon the world.
Use FeedBurner
When it comes to deployment, using FeedBurner is a better option that using your own server. In addition to its statistics, it will also act as a CDN lowering the load on your server.

