The Proper Content Type for XML Feeds
RSS Feeds have a content type problem. Most people end up serving them with the content-type:
text/xml. But this practice is frowned upon for several reasons. The main reason people don't like
text/xml is because its very vague, there are content types such as
that describe the content of your feed much better than
text/xml does. We should be using these types for our feeds.
The problem, however with the more descriptive content types is that Firefox and IE prompt you to download the XML file instead of displaying it in the browser like it would a
So what I have decided to do, is to serve the feeds as
text/xml if the user agent contains
Mozilla. So for IE, Firefox, and Safari 1.x my feed will be served in
text/xml other clients will get the proper
application/rss+xml MIME type. Here's my code for this:
<cfif cgi.user_agent contains "Mozilla"> <cfheader name="Content-Type" value="text/xml"> <cfelse> <cfheader name="Content-Type" value="application/rss+xml"> </cfif>
I realize that this is not a perfect solution, it may cause browser plugins to have to do some extra work to determine if the document is an RSS, RDF or Atom Feed. Additionally if aggregators are including Mozilla in their user agent, they will get
text/xml. But I'm not going to risk loosing potential subscribers over this issue, as some bloggers have reported to be the case when switching.
So I will serve a variable content-type at least until bug 256379 is fixed in a production release of FireFox (or if IE beats them I guess :). You can vote for that bug in bugzilla if you find the save dialog to be annoying when you click on RSS feeds.
I also hope that IE7 is will serve the rss related content-types as it would a text/xml doc by default. Scoble, can you make sure IE7 deals with this? (apparently Robert Scoble will read your post if you put his name in it...)
Tim Bray has pointed out why its important for people to get their act together:
- To manage the traffic load we're going to have to do some caching. Fortunately, RSS contains some publication and expiry-date data to help intermediate software do this, but to do this it has to recognize the data as RSS and read this stuff. This isn't going to happen until RSS gets served with the proper Media-type.
- When someone writes RSS-reader code to live in the Web Browser, it's going to need a consistent Media-type to be able to recognize RSS.
Yet Another Community System cites some of the problems with
text/xml such as the character set issues:
The default character set, which must be assumed in the absence of a charset parameter, is US-ASCII or ISO-8859-1 for all MIME types prefixed by text, depending of the Request for Comment you are considering. Of course, having two different specifications is confusing to the software industry. But also, no one of these two charsets can support complex foreign charsets as those used in Asia. On the other hand, implementors and users of XML parsers tend to assume that the default charset is provided by the XML encoding declaration or BOM.
Like this? Follow me ↯Tweet Follow @pfreitag
You might also like:
- Foundeo's 2007 End of the Year Sale - December 21, 2007
- SoloSub is for button addicts - October 6, 2005
- Finding Feed subscribers from the User Agent - July 25, 2005
- Sessions don't work in Chrome but do in IE - February 6, 2019
- Ajax Same Origin Policy No More with Firefox 3.5 - June 30, 2009
- Firefox 3.5 Introduces Origin Header, Security Features - June 30, 2009
- Geolocation API for Adobe AIR? - October 8, 2008
- Firefox Now Supports HttpOnly Cookies - July 19, 2007