Is one MIME type preferable to ensure compatibility with RSS readers and other scrapers?
The options seem to be:
- text/xml
- text/rss+xml
Interestingly Stackoverflow is using text/html.
Is one MIME type preferable to ensure compatibility with RSS readers and other scrapers?
The options seem to be:
Interestingly Stackoverflow is using text/html.
Neither. It's application/rss+xml
http://www.rssboard.org/rss-mime-type-application.txt
text/xml
.
Apr 19, 2016 at 3:54
Other commenters have pointed out that the single correct mime type is application/rss+xml,
.
However, if you are setting an accept header for a client then
Accept: application/rss+xml, application/rdf+xml;q=0.8, application/atom+xml;q=0.6, application/xml;q=0.4, text/xml;q=0.4
might be a good choice, as it states that it accepts RSS, Atom, and XML (in descending order or preference).
q
parameter, so for the desired effect it would be better to send Accept: application/rss+xml, application/rdf+xml, application/atom+xml, application/xml;q=0.9, text/xml;q=0.8
, which means "Prefer any of the correct MIME types for feeds. If you can't offer that, prefer application/xml
. If you can't offer that, prefer text/xml
. Otherwise, just give me what you've got"
Oct 26, 2015 at 10:02
Accept
headers with the examples of popular feeds in my answer below, and they all returned text/xml
. I used the command: curl -s -H 'Accept: application/rss+xml, application/rdf+xml, application/atom+xml, application/xml;q=0.9, text/xml;q=0.8' -H 'Content-Type: application/rss+xml' -I $f
Apr 19, 2016 at 4:16
Here's a pragmatic answer: whatever the "correct" answer may be (and clearly there is debate about this), text/xml
is the type used by pretty much all the popular feeds out there in the wild.
Here are a few that I checked:
$ for f in \
https://feeds.feedburner.com/TechCrunch/ \
http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml \
http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml \
https://daringfireball.net/thetalkshow/rss \
http://www.npr.org/rss/podcast.php?id=381444908 \
http://feeds.serialpodcast.org/serialpodcast \
http://podcasts.joerogan.net/feed \
https://feeds.feedburner.com/thetimferrissshow \
http://feed.thisamericanlife.org/talpodcast ; do \
curl -s -I $f | fgrep -i Content-Type: ; done
content-type:text/xml; charset=UTF-8
Content-Type: text/xml
Content-Type: text/xml
Content-Type: text/xml;charset=UTF-8
Content-Type: text/xml;charset=UTF-8
Content-Type: text/xml; charset=UTF-8
Content-Type: text/xml; charset=UTF-8
content-type:text/xml; charset=UTF-8
Content-Type: text/xml; charset=UTF-8
So you can be sure that text/xml
will be correctly interpreted by commonly used RSS clients.
The most correct is application/rss+xml
The most compatible is application/xml
According to W3C:
RSS feeds should be served as application/rss+xml (RSS 1.0 is an RDF format, so it may be served as application/rdf+xml instead). Atom feeds should use application/atom+xml. Alternatively, for compatibility with widely-deployed web browsers, any of these feeds can use one of the more general XML types - preferably application/xml.
https://validator.w3.org/feed/docs/warning/UnexpectedContentType.html
application/rss+xml
has any practical compatibility issues, so there is no point to use xml
mimetype.
Nov 21, 2021 at 21:19
Go for MIME application/rss+xml to be safe if you want to make sure your feed is compatible with RSS readers and other scrapers. That's what I use.
You could use text/xml
, but the correct MIME type would be application/rss+xml
.
application/xml
is prefered over text/xml
because XML doesn't follow normal text content encoding rules. It can embed its encoding in its data, which will cause problems if proxies try to blindly transcode the text. In other words, proxies are instructed to preserve the data byte-for-byte.
text/xml is the only correct answer. Mime types are a registration based system. There is an official list managed by IANA (Internet Assigned Numbers Authority) at http://www.iana.org/assignments/media-types/media-types.xhtml
application/rss+xml
was never registered at IANA. There was an application draft that expired long ago. ietf.org/archive/id/draft-nottingham-rss-media-type-00.txt That is also the reason why Debian doesn't serve RSS with the correct MIME type bugs.debian.org/cgi-bin/bugreport.cgi?bug=605250