Internet technology hosted by Berkman Center

How to support enclosures in aggregators

Friday, July 18, 2003


RSS 2.0 has a neat feature that allows an item to have an enclosure.

Like the enclosure of an email message, an RSS item enclosure is something big that may take a long time to download, or something binary that isn't text you read. You can read the text that describes the enclosure, or the enclosure may somehow be related to the item.

An example. Suppose a news source, like the NY Times runs a movie review. It might make sense to enclose a trailer for the movie along with the review. Or a band might use RSS to keep their fans informed of what they're up to. An enclosure could include a bit of music to illustrate a point.

The cool thing about enclosures is that they can be time-shifted. The aggregator or news readers should not download the enclosure until the computer is idle, and should not present the item with the enclosure to the user until the enclosure has been downloaded and is resident on the local hard disk. The key premise is No More Click-Wait.

Please read the background piece for more on the philosophy of enclosures. This article is a walkthrough for developers showing them how to support this feature of RSS.


Adam Curry is a television personality with several weblogs and his own reality show called Adam's Family. He was also one of the first video jocks on MTV in the 1980s. He was the guy with the fantastic hair, and great sense of humor.

Adam uses a weblog tool that allows him to include an enclosure on any item. To do so, he enters the item as he normally would, perhaps giving it a title and a link, routing it to one or more categories, and then enters the URL for an enclosure. Screen shot.

As his weblog tool generates the RSS feed for his site, it reads the header for the enclosed file to determine its size, and looks up its content type in a table (based on the extension) and creates an <enclosure> sub-element of the <item>. If there's an error (e.g. the file doesn't exist, or there was no content-length header), the error is logged and the enclosure element is omitted from the feed.

Now, on the receiving end, I have subscribed to Adam's feed in my news aggregator. In its hourly scan, the aggregator notes that there's a new item that has an enclosure. It adds the information about the enclosure to a table it's keeping, of enclosures that have not yet been downloaded.

When I'm finished for the day I leave my computer on. I like to have my aggregator check new feeds every hour even when I'm not there, and I also like to give it a chance to download enclosures so the clips that Adam creates will ready for me to watch when I arrive at work early the next morning.

Sure enough, yesterday Adam released a new installment of his reality show, and the QuickTime movie, all 34 megabytes of it, is on my hard drive, just waiting for me to watch. There's a note on the desktop website home page alerting me to its existence. I fill up my cup of coffee and then sit down to watch the latest from Adam's family in the Netherlands.


Enclosures are a powerful feature of RSS 2.0 waiting to be used. Today, like the early days of the Web, a few pioneering souls are experimenting. In the coming months and years the Internet will be used to distribute news and entertainment we now depend on television and radio to distribute. This is the beginning of a network that will do the distribution. It may well be an important point of integration between RSS and P2P technologies.