0

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 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

memCache lives in memory and is ment for small data. While I am looking to hold large amount of data and therefore I rather use the hard drive to hold the data.
@mashtagidi - You should really have included the size of data you need to cache. I don't really see the point of using the disk as a cache as this is just as slow as anything.
"Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects)". My app needs to store a few milion keys, but the size of each key is not so big (the largest object can contain a list of a few thousands records, but usually it is one object with a 20-30 properties). Does memcached suit my needs?
0

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.

2 Comments

right now I have only one site and not a web farm. but the thing is if my static data is not cached, it will be alot slower to pool it.
To keep your cached values on a iis process recycle you can leverage the same mechanism as webfarms do. even if you run on a single box. no matter how you call it "shared", "distributed" or "out of process" cache. to take the cache out of process does the trick to keep cached content on recycles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.