ASP.net Cache Absolute Expiration not working

后端 未结 3 1552
渐次进展
渐次进展 2021-02-07 11:17

I am storing a single integer value in HttpContext.Cache with an absolute expiration time of 5 minutes from now. However, after waiting 6 minutes (or longer), the integer value

3条回答
  •  逝去的感伤
    2021-02-07 12:08

    Try using DateTime.UtcNow to calculate your timeout period instead of datetime.Now . You may be running into the issue described below:

    absoluteExpiration Type: System.DateTime The time at which the inserted object expires and is removed from the cache. To avoid possible issues with local time such as changes from standard time to daylight saving time, use UtcNow rather than Now for this parameter value. If you are using absolute expiration, the slidingExpiration parameter must be NoSlidingExpiration.

提交回复
热议问题