Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RSS 2.0 and Atom 1.0: Required headers?

Tags:

php

rss

atom-feed

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...

like image 755
keanu_reeves Avatar asked Nov 04 '25 22:11

keanu_reeves


1 Answers

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.

like image 58
atymic Avatar answered Nov 06 '25 13:11

atymic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!