What is the difference between absolute expiration and sliding-time expiration?
Jhaon Pitter
ASP.NET provides the functionality to create cache. It also provides the option to set the expiration time after which the cache would no longer be available. This is called "Time Based Expiration". This expiration is of 2 types: 1. Absolute Expiration 2. Sliding ExpirationIn Absolute Expiration the cache will be expired after a particular time irrespective of the fact whether it has been used or not in that time span. Whereas, in Sliding Time Expiration, the cache will be expired after a particular time only if it has not been used during that time span.The syntax to declare them are as follow:string cacheData = "Let's cache this data"; //Absolute Expiration Cache.Insert("AbsoluteCacheKey", cacheData, null,DateTime.Now.AddMinutes(1), System.Web.Caching.Cache.NoSlidingExpiration); //Sliding Expiration Cache.Insert("SlidingExpiration", cacheData, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1));n above example I have created the a string to be cache that can be any serialized data. In the absolute expiration you can see that it will expires after one minute whether its accessed or not. While in sliding expiration it will expire cache if cache is not accessed within specified time like one minute.