keanu_reeves
keanu_reeves

Reputation: 370

RSS 2.0 and Atom 1.0: Required headers?

I have a pretty basic question for yall:

What are the required headers for an Atom 1.0 feed?

Also, what are the required headers for an RSS 2.0 feed?

I know that you can set headers for a sitemap (XML document) that way:

header('Content-type: text/xml');
header('Pragma: public');
header('Cache-control: private');
header('Expires: -1');

What would be the correct syntax for those two?

Cheers.

PS. I thought it was quite silly to make two separate questions considering they're both so similar...

Upvotes: 4

Views: 1916

Answers (1)

atymic
atymic

Reputation: 3128

The correct header Content-Type header for an Atom feed is application/atom+xml. However, Chromium does not handle it correctly (Issue 104358: RSS feeds are not parsed correctly).

The most compatible header is text/xml;charset=UTF-8, which will cause the feed to be parsed correctly by most clients. Note that you should be encoding your feed in UTF8.

header('Content-type: text/xml;charset=UTF-8');

In regards to the other headers, they are just telling the client not to cache the feed.

Upvotes: 6

Related Questions