Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 467
Tawani Avatar asked Dec 30 '25 02:12

Tawani


2 Answers

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.

like image 168
Paddy Avatar answered Dec 31 '25 17:12

Paddy


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.

like image 44
Josh Pearce Avatar answered Dec 31 '25 17:12

Josh Pearce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!