{"id":117,"date":"2008-07-17T23:21:29","date_gmt":"2008-07-17T17:51:29","guid":{"rendered":"http:\/\/www.bin-co.com\/blog\/?p=117"},"modified":"2008-07-17T23:21:29","modified_gmt":"2008-07-17T17:51:29","slug":"rules-for-creating-an-rss-feed","status":"publish","type":"post","link":"https:\/\/www.bin-co.com\/blog\/2008\/07\/rules-for-creating-an-rss-feed\/","title":{"rendered":"Rules for Creating an RSS Feed"},"content":{"rendered":"<p><a href='http:\/\/feeds.feedburner.com\/bin-blog'><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bin-co.com\/blog\/wp-content\/uploads\/2008\/07\/rss_feed.png\" alt=\"\" title=\"RSS Feed\" width=\"158\" height=\"158\" class=\"alignnone size-full wp-image-118 intro\" align=\"right\" \/><\/a><\/p>\n<p class=\"intro\">Most of us don&#8217;t have to worry about creating an RSS feed for our sites &#8211; the <abbr title=\"Content Management System\">CMS<\/abbr> tool will do that automatically. But there are times when you are creating a custom application &#8211; when you have to create an RSS feed yourself. Creating it is easy &#8211; they don&#8217;t call it <strong>Really Simple<\/strong> Syndication for nothing. But there are a few rules(or rather, guidelines) that are ignored by most &#8211; make sure you follow them.<\/p>\n<p>I am by no means an expert on this format &#8211; but I have created <a href=\"http:\/\/www.openjs.com\/rss.php?no_redirect=1\">RSS feeds<\/a> and have <a href=\"http:\/\/www.bin-co.com\/blog\/2008\/02\/alertle-launched\/\">worked<\/a> on  <a href=\"http:\/\/www.alertle.com\/\">applications<\/a> to <a href=\"http:\/\/www.bin-co.com\/php\/scripts\/xml2array\/\">parse<\/a> it. So I have seen my share of bad implementations.<\/p>\n<h2>Use RSS rather than Atom<\/h2>\n<p>I prefer using <a href=\"http:\/\/en.wikipedia.org\/wiki\/RSS_(file_format)\">RSS<\/a> as opposed to the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Atom_(standard)\">Atom format<\/a>. But Atom is now supported on almost all feed readers &#8211; so this preference may change. But for now, I like RSS better than Atom.<\/p>\n<h2>Last-Modified<\/h2>\n<p>Make sure your feed has the <a href=\"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec14.html#sec14.29\">last modified header<\/a>. This will prevent unnecessary downloading of the feed if there are no new articles. It <a href=\"http:\/\/feedparser.org\/docs\/http-etag.html\">saves both the site&#8217;s and the user&#8217;s bandwidth<\/a>.<\/p>\n<p>This is extremely easy in PHP&#8230;<\/p>\n<pre><code class=\"php\">$last_edited = '2008-07-17 01:02:03'; \/\/ This should be the time of the latest post.\nheader(\"Last-Modified: \" . date('r',strtotime($last_edited)));<\/code><\/pre>\n<h2>10 Posts<\/h2>\n<p>Make sure you provide a limited number of posts in the feed &#8211; the perfect number, in my opinion, is 10. It can increase or decrease a bit &#8211; 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.<\/p>\n<p>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 &#8211; <a href=\"http:\/\/www.catandgirl.com\/rss.php\">Cat and Girl Comic feed<\/a>.<\/p>\n<p>The other extream is just as bad &#8211; 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 <a href=\"http:\/\/www.viruscomix.com\/rss.xml\">subnormality comic<\/a>.<\/p>\n<h2>Validate it<\/h2>\n<p>XML is not as forgiving as HTML &#8211; so make sure you <a href=\"http:\/\/www.feedvalidator.org\/\">validate your feed<\/a> before releasing it upon the world.<\/p>\n<h2>Use FeedBurner<\/h2>\n<p>When it comes to deployment, using <a href=\"http:\/\/www.feedburner.com\/fb\/a\/home\">FeedBurner<\/a> is a better option that using your own server. In addition to its statistics, it will also act as a <abbr title=\"Content Distribution Network\">CDN<\/abbr> lowering the load on your server.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Some rules for creating an RSS feed.<\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,30,32],"tags":[48,112,118,241,243,297],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-opinion","category-web-development","category-xml","tag-atom","tag-feed","tag-format","tag-rss","tag-rule","tag-web"],"_links":{"self":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}