What is the lifespan of the HttpRuntime Cache (any simple alternative?)

2.1k views Asked by At

I have been using the HttpRuntime Cache for caching simple user preferences on an in house [dasboard] asp.net app that gets used by almost 200 users daily.

I simply cache stuff such as the last query conditions, scales, options (just checkboxes dependent on other checkboxes etc.) just so that when a user closes the browser, they will be returned to the exact dashboard/report option the next time they open the browser.

I do not want to use the database to cache these values because they are "unlimited" and "dynamic".

Anyway, the HttpRunime Cahce has been working fine but now every once in a while it doesn't work on the production server. Is there any approach to fix this problem?

2

There are 2 answers

1
Paddy On BEST ANSWER

The cache is application wide - are you cacheing these items on a per user basis?

The cache will periodically die, and you have no control over this - if you need these items to persist, then DB cacheing may the only way to go.

Edit - as to the unlimited and dynamic, you could potentially store them in an XML field in the database. If you have an object where they are currently stored in the cache, it would be relatively easy to serialize/deserialize this from the DB, if the cache is empty.

0
Josh Pearce On

There are timespan and absolute expiration settings available qhen you insert into cache, but when the app pool recycles, the cache is wiped out. Check your App Pool setting in IIS, and see how frequently it recycles.