Hey guys,
I'm currently thinking about caching most of my viewdata excpt user specific data after a user logs on. I thought the simplest way was caching the ViewData object itself and adding the user specific data after it was loaded. Are there any downsides of this approach? Are there better ways?
string cacheKey = "Nieuws/show/" + id;
if (HttpRuntime.Cache[cacheKey] != null)
{
ViewData = HttpRuntime.Cache[cacheKey] as ViewDataDictionary;
}
else
{
// add stuff to view data
HttpRuntime.Cache.Insert(cacheKey, ViewData, null, DateTime.Now.AddSeconds(180), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, null);
}