EDIT: This is not a question on how I can programatically set expiration. I am fully versed in absolute, sliding, and dependency expiration.
When an item is stored in the ASP.NET cache, is there some known algorithm used by ASP.NET to determine when that item will be removed?
I don’t mean if it’s been invalidated (say by use of SqlCacheDependency notification), but rather some element that got loaded and cached and then hasn’t been touched/read in hours or days… or even minutes but on a server where cache memory is in constant demand… is there some published information on how IIS or ASP.NET decide when idle data should be wiped out?
I ask because my boss is thinking that maybe we can out-think IIS, and force nightly pre-loads of data into the cache that we think will be likely to be needed. I think this is a futile effort likely to put us in competition with the real needs of the app – so I’m looking for some hard material that validates or disproves my thinking.
TIA
G
Cache has to be cleaned from time to time in order to ensure that there is a place to store new items. Data from cache can also be removed when the time when the item is valid has expired or when dependencies have changed. Dependency can be for example a database – then when there were some changes in database the item that depends on this database is removed from cache.
There are two mechanisms that clear data stored in cache:
Scavenging – when there is not enough free space in cache ASP.NET looks for items which haven’t been recently used and for items with low priority. Then it deletes selected items and stores new items in cache.
Expiring – data for which time when they are valid has passed is also removed. Expiration times can be absolute – when data is valid for a specific period of time and they can also be so called “sliding” when time is counted always from the beginning from the last use