RSS Viewer Web Part Making Excessive Requests
I was investigating a scenario in which someone was seeing thousands of hits to the destination location of an RSS Viewer Web Part. They had the Feed Refresh Interval set to 120 minutes, and increasing the value did not seem to reduce the number of requests hitting the RSS Feed page.
We were able to track this down to how the RSS Feed requests are cached. The RSS Viewer Web Part leverages the XmlUrlDataSource class to call the location for the RSS Feed. This class is also responsible for handling the cache of the response from the RSS Feed. The reason this is important, is because this class creates a cache key in the following format:
URL + tab + Name
This would indicate that for each RSS Viewer Web Part, if you set the cache for 24 hours, you will end up with a request for each distinct user back to the RSS Feed. For example, if you have 1,000 distinct users accessing a page with the RSS Viewer web part, you would see 1,000 requests to the RSS Feed location.
To validate what I was finding, I put together a Visual Web Part that dumps out the keys in the ASP.Net Cache. This cannot be a sandboxed solution due to the code needing to execute in the application pool hosting ASP.Net, and it’s associated cache.
ASCX file has the following:
<asp:BulletedList ID=”BulletedList1” runat=”server”/>
Page load in the .cs file has the following:
1: ArrayList keys = new ArrayList();
2:
3: foreach(DictionaryEntry cacheEntry in HttpRuntime.Cache)
4: {
5: keys.Add(cacheEntry.Key);
6: }
7:
8: BulletedList1.DataSource = keys;
9: BulletedList1.DataBind();
I then added an RSS Viewer Web Part to a page pointing to an anonymous feed on TechNet. Then added my visual web part. I logged into SharePoint with two separate accounts, and the Visual Web Part output shows two separate cache entries. In my case, I have a domain with my account, as well as an account for Bob Smith. The cache has the following two entries:
https://www.microsoft.com/feeds/technet/en-us/TechNetNewsFeed.xml Bob Smith
https://www.microsoft.com/feeds/technet/en-us/TechNetNewsFeed.xml Jerry Orman
Comments
Anonymous
October 18, 2011
The RSS viewer web-part use your identity to get security trimmed results, thus it must cache per user to ensure you don't see other users' results. That is also why you need Kerberos to read feeds from other parts of SharePoint, to be able to delegate the identity for security trimming.Anonymous
October 23, 2011
@KjellSJ - Thanks for posting the comment! Forgot to include that info in the post :-)Anonymous
August 15, 2014
Rss Feed can be very helpful if updated regularly with new content. ThanksAnonymous
January 12, 2015
foreach(DictionaryEntry cacheEntry in HttpRuntime.Cache) { keys.Add(cacheEntry.Keys); } BulletedList1.DataSource = keys; wroong :( http://thuongtin.co/