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
The Proper Content Type for XML Feeds was first published on June 13, 2005.
If you like reading about rss, xml, atom, rdf, content-type, http, mime, firefox, ie, or mozilla then you might also like:
- Foundeo's 2007 End of the Year Sale
- SoloSub is for button addicts
- Finding Feed subscribers from the User Agent
- One liner to download a Browser with PowerShell on Windows Server
- Sessions don't work in Chrome but do in IE
- Ajax Same Origin Policy No More with Firefox 3.5
- Firefox 3.5 Introduces Origin Header, Security Features
- Geolocation API for Adobe AIR?