I am using HttpRuntime.Cache to store my site cache. The problem is whenever I want to upload a new updated compiled version, the site's cached is being deleted. I would love to know about ways to overcome this. thx in advance to all dear helpers.
2 Answers
The cache lives in memory - once you upload a new version of your site, IIS recycles the application pool, meaning the memory is cleared and the cache with it.
You can't change how this works.
You can persist the cache to disk (or database or something else) and read that, but you are probably better off just letting things stay as they are.
An alternative it to use a separate cache server - something like memcached that is completely separate from IIS.
3 Comments
To use a shared (or distributed) cache would solve your issue. Such caches are also used in webfarm environment where several web servers need access to data in a shared cache.
Have a look at AppFabric which is Microsofts distributed cache implementaion (it's free)
There are many other caching products availbale like NCache, MemCached, GemFire or Oracle Coherence to name just a few.