Hacker News new | past | comments | ask | show | jobs | submit login

This is very cool and I explored doing this with our feeds at Standard Ebooks.[0]

But there's a gotcha:

This works fine if you serve the feed with `content-type: text/xml`, because with that content type the browser typically renders the result in-browser. But `text/xml` is technically not the correct content type for RSS feeds, `application/rss+xml` is; and when you serve it with that content type, browsers typically either open a download window instead of rendering the feed, or they render it as plain text without styling.

So you're stuck. Have a styled feed but serve it with the wrong content type, or be technically correct and serve it with the right content type, but no styling for you.

Practically, content type really doesn't matter that much, and most (all?) RSS readers are fine with `text/xml`. But for those of us who like to be technically correct...

[0] https://standardebooks.org/feeds/rss/new-releases




Content negotiation is a thing that should be used. My browser sends this in the request headers when I open up one of those RSS links:

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Which means it would prefer to get a response from the server in (basically) the order shown, but it will accept any response type (*/*). So ideally the server would be using that information and making the decision to serve the RSS feed as application/xml instead of application/rss+xml. AFAIK if the "subtype" (rss+xml in this case) has a + in it, then it basically means it conforms to the format after the + (e.g. application/xml) and thus is just providing a bit more context, but is still valid as the more generic version.

Though I do think the browser should also keep that same thing in mind and attempt to render any application/whatever+xml in its XML renderer.

Edit: another thing you could try to add this response header:

    Content-Disposition: inline


That's a great idea. I've gone ahead and implemented it!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: