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;
Kelsey
source share