System.Web.Caching & System.Runtime.Caching against IIS App Pool restarts

909 Views Asked by At

In Asp.net Forms or MVC application, cache items which use System.Web.Caching get clear in an app pool restart. But what happens if caching was achieved using System.Runtime.Caching ?

1

There are 1 best solutions below

2
On BEST ANSWER

But what happens if caching was achieved using System.Runtime.Caching ?

If you are using the MemoryCache default implementation then exactly the same will happen because the items will be stored in memory of the AppDomain. If you want your cache items to survive application pool restarts you might need to use a distributed cache system such as Redis or Memcached. By using a distributed cache system all the nodes of your web cluster will have access to those cache items and might take advantage of them.