I’m wondering if there are any differences between MemoryCache and HttpRuntime.Cache, which one is preferred in ASP.NET MVC projects?
As far as I understand, both are thread safe, API is from first sight more or less the same, so is there any difference when to use which?
HttpRuntime.Cachegets theCachefor the current application.The
MemoryCacheclass is similar to the ASP.NETCacheclass.The
MemoryCacheclass has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NETCacheclass.The main difference between
HttpRuntime.CacheandMemoryCacheis that the latter has been changed to make it usable by .NET Framework applications that are not ASP.NET applications.For additional reading:
Update :
According to the users feedback, sometimes Jon davis blog is not working.Hence I have put the whole article as an image.Please see that.
Note : If it’s not clear then just click on the image.After that it’ll open on a browser.Then click again on it to zoom 🙂