Frequently Asked Interview Questions

Sliding Expiration and absolute Expiration in asp.net caching

What is Sliding Expiration and absolute Expiration in asp.Net Caching?


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)


Caching FAQSASP.NET Caching Article

Most Visited Pages

Home | Site Index | Contact Us