Asp.Net: Caching Rss feeds

by Pieter Brinkman 3. March 2009 09:10

For dotNetSearch.net I needed to cache the RSS feed (on the right). I did this with the .Net Cache namespace.

if(Cache.Get(RssUrl) == null)
{
 RssDocument rssFeed = RssDocument.Load(new Uri(RssUrl));
 Cache.Insert(RssUrl, XDocument.Parse(rssFeed.ToXml(DocumentType.Rss)), null, DateTime.Now.AddMinutes(15), TimeSpan.Zero);
}

XDocument rssXml = (XDocument)Cache.Get(RssUrl);


In this examle I add the RSSFeed content as object in the cache and use the url of the RSS feed as Key. The Cache will expire (and cleared) after 15 minutes.

 

Tags: , ,

ASP.Net

Comments

4/24/2009 5:37:59 AM #

Terry Walker

Good post, but have you thought about Asp.Net: Caching Rss feeds before?

Terry Walker United States

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am Solution Architect for Sitecore in The Netherlands. My interests are mainly ASP.NET, MSSQL and Content Management Systems.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

RecentComments

Comment RSS

Most comments