What is Absolute and Sliding expiration?

 Posted by ArticlesMaint on 9/17/2009 | Category: ASP.NET Interview questions | Views: 13963

Absolute Expiration allows you to specify the duration of the cache, starting from the time the cache is activated. The following example shows that the cache has a cache dependency specified, as well as an expiration time of one minute.

Cache. Insert ("announcement", announcement, depends, _DateTime.Now.AddMinutes(1), Nothing)

Sliding Expiration specifies that the cache will expire if a request is not made within a specified duration. Sliding expiration policy is useful whenever you have a large number of items that need to be cached, because this policy enables you to keep only the most frequently accessed items in memory. For example, the following code specifies that the cache will have a sliding duration of one minute. If a request is made 59 seconds after the cache is accessed, the validity of the cache would be reset to another minute:

Cache.Insert("announcement", announcement, depends, _Date Time. Max Value, _TimeSpan.FromMinutes(1))

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response