Best implementation for RSS feed in C # (ASP.net)

I have a web application (asp.net) that must have a feed. Therefore, I used the System.ServiceModel.Syndication to create a function that creates news. The fact is that it is executed every time someone calls it, should I only use it to create an xml file and make my rss URL for the file?

What is the best approach?

Edit: Maybe where I am wrong. I don't use a handler ... I just use a WCF service that returns an Rss20FeedFormatter with data.

+7
performance architecture rss syndication
source share
3 answers

In the past, when I implemented RSS, I cached RSS data in HttpContext.Current.Cache.

RSS data usually does not need to be updated frequently (for example, once a minute is more than enough), so you only need to click the database once a minute, and not every time someone requests your RSS data.

Here is a cache usage example:

 // To save to the cache HttpContext.Current.Cache.Insert("YourCachedName", pObjectToCache, null, DateTime.UtcNow.AddMinutes(1), System.Web.Caching.Cache.NoSlidingExpiration); // To fetch from the cache YourRssObject pObject = HttpContext.Current.Cache[("YourCachedName"] as YourRssObject : null; 

You can also install the following in your ashx:

 context.Response.Cache.SetExpires(DateTime.Now.AddMinutes(1)); 

This will cause your RSS page to be cached until it expires. This requires even less resources, but if you have other things that use your RSS data access level calls, this will not cache this data.

You can also make it a cache based on the request parameter that your RSS can receive by setting:

 context.Response.Cache.VaryByParams["YourQueryParamName"] = true; 
+8
source share

ASP.Net has pretty good server-side caching. Assuming you use these classes as part of a regular aspx page or http (ashx) handler, you can simply say that ASP.Net will cache it aggressively, build your channel for every request.

+1
source share

On your .aspx page, you cannot just use:

 <%@ OutputCache Duration="60" VaryByParam="none" %> 

I have a blog entry where I have the results of a stored procedure sent to my phone as an RSS feed HERE.

0
source share

All Articles