The RSS Blog

News and commentary from the cross-platform RSS and OPML community.

Moving and Retiring RSS Feeds

OK, now for some really boring and really important stuff. What do you do with your old feed when you change blogs? Or what do you do with your old feed when you don't need it anymore? You don't want people polling those feeds 'til the end of time. Somehow, we have to tell RSS clients that you don't exist anymore. In RSS-ville, there's countless ways of doing this and most of them don't work anyway. As such, I'm writing yet another tutorial that RSS developers will likely ignore. I hate them :-( I hate them all ;-) But in case you actually care, here's how to move and retire an RSS feed. This is not new content and is also covered in the HowTo RSS Feed State article.

I'm gonna break this tutorial into two parts. The first part is when you want to move an RSS feed to another place, domain, blog, or whatever. The second part is when you don't care anymore and you want your readers to simply go away and free up some bandwidth.

Moving an RSS Feed

In doing my own testing, I put together a very dynamic RSS feed where all these various move operations will be moving to. The first and most proper way of moving an RSS feed is to respond to the HTTP request with a 301 Permanent Redirect. I've prepared a small ASPX file that simulates exactly this type of response. The code for ASP.NET is shown.

<%@ page language="C#" %>
<%
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "https://rssweblog.com/media/rss-dynamic-test.xml");
%>

If you reuse this code, simply change the URL in the AddHeader call to the target URL where your RSS feed is moving to.

For the really geeky nerds out there, this is what a 301 redirect looks like at the wire level. The first two lines are the client request and the last four are the server response. I removed a couple headers that were irrelevant to the discussion.

GET /rss/test/http-301.aspx HTTP/1.1
Host: www.rssweblog.com

HTTP/1.1 301 Moved Permanently
Date: Fri, 10 Nov 2006 17:55:11 GMT
Location: https://rssweblog.com/media/rss-dynamic-test.xml
Content-Length: 0

Of course, not everybody has HTTP level access to their website or the skill required to generate such a response. In those cases, you may want to consider an XML-level redirect. Here's a sample XML-level redirect:

<?xml version="1.0" ?>
<redirect>
<newlocation>https://rssweblog.com/media/rss-dynamic-test.xml</newlocation>
</redirect>

To use this technique save a copy of this XML to a file and change the URL of the target RSS feed to the URL where your RSS feed is moving to. You may have to escape some characters in your target URL. Change > to &gt; < to &lt; and & to &amp;. If you struggle with such escaping, then drop me an email. Finally, rename the file to the same filename as your RSS feed and copy the file to your web server, replacing your old RSS file.

Again for the geekoids, here's what the XML-redirect looks like on the wire.

GET /media/rss-dynamic-test.xml HTTP/1.1
Host: www.rssweblog.com

HTTP/1.1 200 OK
Content-Length: 121
Content-Type: text/xml
Last-Modified: Fri, 10 Nov 2006 16:21:37 GMT
Accept-Ranges: bytes
ETag: "2268c84be44c71:d84"
Date: Fri, 10 Nov 2006 17:57:19 GMT

<?xml version="1.0"?>
<redirect>
  <newLocation>https://rssweblog.com/media/rss-dynamic-test.xml</newLocation>
</redirect>

Assuming options A and B are not possible, the next best way is a 302 Temporary Redirect. But this method is really wasteful because the client software will continue to use the original URL and be redirected every-time to the new URL. Wasteful indeed.

If all of A, B and C are not possible, then a last option is to put a blog entry that specifically asks your readers to re-subscribe using the new URL.

Retiring an RSS Feed

Great, we know how to move an RSS feed, but just how do we go about killing one that is no longer required? The best way to tell a client that a feed is no longer used is to response with a HTTP 410 Gone response. Here's a sample 410 gone response.

The ASP.NET code for a 410 gone response.

<%@ Page Language="C#" %>
<%
Response.Status = "410 Gone";
%>

And here's what it looks like on the wire.

GET /rss/test/http-410.aspx HTTP/1.1
Host: www.rssweblog.com

HTTP/1.1 410 Gone
Date: Fri, 10 Nov 2006 18:02:32 GMT
Content-Length: 0

Some RSS clients will prompt the user to remove the feed when this response is encountered. Others will simply stop polling the feed or even unsubscribe the user without requiring any confirmation.

If you can't figure out how to do a 410 Gone response, then you can also use an XML-level redirect to accomplishes the same. Here's a sample XML-level redirect that tells the RSS client that the feed should be unsubscribed:

<?xml version="1.0"?>
<redirect>
<newLocation/>
</redirect>

Note this XML-level redirect is similar to previous, except that no new RSS feed is provided.

And finally, here's what a XML-level unsub looks like on the wire.

GET /rss/test/xml-gone.xml HTTP/1.1
Host: www.rssweblog.com

HTTP/1.1 200 OK
Content-Length: 64
Content-Type: text/xml
Last-Modified: Fri, 10 Nov 2006 16:21:37 GMT
Accept-Ranges: bytes
ETag: "de1aba4be44c71:d84"
Date: Fri, 10 Nov 2006 18:10:18 GMT

<?xml version="1.0"?>
<redirect>
  <newLocation/>
</redirect>

If anybody has PHP code or other similar to the ASP.NET code above, then feel free to post them in the comments. If you post them in the next few days, then I'll likely add them to the content of the original article. And a big thanks in advance.

Reader Comments Subscribe
Fri, 10 Nov 2006 23:33:29 GMT
Sun, 12 Nov 2006 00:06:54 GMT

Simone Carletti sent me the PHP solution. Very similar to ASP.NET.

<?php
header("HTTP/1.0 301 Moved Permanently");
header("Location: https://rssweblog.com/media/rss-dynamic-test.xml");
?>
Mon, 13 Nov 2006 23:54:57 GMT

I shared a link to this on frEdSCAPEs.

Tue, 14 Nov 2006 15:46:33 GMT

How is this done with TypePad and it's index.rdf file?

Hans Mestrum

Tue, 05 Dec 2006 01:32:52 GMT
Type "339":