How do I find out that a feed reader is accessing my page?

I would like to use different content from the same url depending on whether the user is a browser or an RSS reader (hence avoiding the example.com/feed url). So www.example.com/posts will return an HTML page (X) to the browser and an RSS feed to the feed reader.

What is the most appropriate way to solve this problem for this purpose?

PS Like this for the soft ball question ... :)

0


source to share


2 answers


I'm not sure if this is possible in all situations. Consider a user who is using the Safari RSS reader, assuming they are using the same browser id string when they load the RSS feed, how would you report all of these two modes?



I would really revisit this approach, there is nothing wrong with having a separate feed url.

+5


source


Let me introduce you to the User-Agent HTTP header. It will contain the identification string for the client to access your page. It might be fake, but you just can't be 100% sure it's an RSS reader or browser.

Additionally, RSS readers can send Accept headers for rss content types, which you can use to implement content negotiation ( MultiViews in Apache).



But since there is no sure fire path, you are better off failing on the serving side of HTML more often than RSS, or better yet, do what everyone else is doing and provide a different feed for RSS.

+2


source







All Articles