views:

121

answers:

3

I've been using System.Web.Cache for a while for testing purpose. It's quite a nice cache store and speed up my webpage quite a lot. But i don't know there are some case, in which i run for a few more more page, and when I turn back to that page few more time, the page query again ( I checked using a profiler ).

Does System.web.cache cache in Ram or some type of flash memory that make the cache go off once in a while when it's low on memory? or is it my mistake somewhere? Is it good to use System.web.cache for production?

best wishes to you :)

+3  A: 

The cache will automatically start removing items when your system runs low on memory, the items it picks can be controlled to some degree by the priority you give them when you insert them into the cache. Use the CacheItemPriority enum to specify the priority in the Cache.Add() method. Yes the cache is fine for production, whether it is good or not for your specific implementation only you can tell.

bleeeah
You can also provide a callback method in the Cache.Add() method that is called when the item is removed from the cache. This will give you the reason the item was removed.
bleeeah
thank you for this very useful information :)
DucDigital
+1  A: 

Yes, ASP.NET cache is perfectly fine for production use (however, consider Velocity if you have a web farm). And yes, it does automatically remove items based on memory, item priority & other "metrics".

Anton Gogolev
im looking between memcached and velocity, i want to check out the speed since memcached is not originally for Windows so im not sure of it's perfomance.
DucDigital
+3  A: 

The other issue to watch for is when the IIS application pool gets recycled.

Martin Clarke