Most 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.
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)));
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.
XML is not as forgiving as HTML – so make sure you validate your feed before releasing it upon the world.
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.
Thanks for dat awesome tip!
Thanks for that tips Binny.
I guess the code snippet in PHP will come handy.
Why the preference of RSS over Atom? Most vs-articles I have read mark Atom as the superior format. Either way, I’m of the opinion that both are ubiquitous, just choose one over the other – using both only serves to confuse people.
Even I am not clean on why I choose RSS over Atom. But I have been working on this for some time – and I have found that RSS is more simpler for me to use – so I prefer it. It may be due to my lack of experience with Atom. As I said in the article, my preference my change anytime.