Frequently Asked Interview Questions

ASP.NET Caching FAQS

ASP.NET Caching FAQS Page 2
Sliding Expiration: With sliding expiration, ASP.NET waits for a set period of inactivity to dispose of a neglected cache item.
Ex:
Cache.Insert("MyItem",obj,null,DateTime.MaxValue, TimeSpan.FromMinutes(10)) --> The cached data will be removed only if it is not used within a ten-minute period.

Absolute Expiration: With absolute expiration, we set a specific date and time when the cached item will be removed.
Here’s an example that stores an item for exactly 60 minutes:

Cache.Insert("MyItem",obj,null,DateTime.Now.AddMinutes(60), TimeSpan.Zero)
Two types of cache dependency available in .Net
1.File and Cache Item Dependency :- Cache item can be dependent on a particular file. On modification of this file, cache will be invalidated.
2.Dependencies on a database query :- cache items can be depenedent on sql queries as well, any changes to sql data, cache will be invalidated.
The OutputCacheModule
Caching in Asp.Net is implemented as an HttpModule that listens to all HttpRequests that come through the ASP.NET worker process.
  • The scope of both variables are in Application level.
  • Cache variable provide cache specific features (i.e. expiration).
  • Cache data depends on cache memory, If server running very low cache memory it will remove cached items based on priority.
  • The scope of the Cache variable is Application level, sessions variable can be accessed with in session.
  • Cache variable provide cache specific features (i.e. expiration).
  • Cache data depends on cache memory, If server running very low cache memory it will remove cached items based on priority.

Most Visited Pages

Home | Site Index | Contact Us