.NET Caching how does Sliding Expiration work?

前端 未结 2 2064
Happy的楠姐
Happy的楠姐 2020-12-29 18:10

If I use an ObjectCache and add an item like so:

ObjectCache cache = MemoryCache.Default;
string o = \"mydata\";
cache.Add(\"mykey\", o, DateTime.Now.AddDays         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 18:30

    The SlidingExpiration property value is set using the slidingExpiration attribute of the configuration element. Sliding expiration resets the expiration time for a valid authentication cookie if a request is made and more than half of the timeout interval has elapsed. If the cookie expires, the user must re-authenticate. Setting the SlidingExpiration property to false can improve the security of an application by limiting the time for which an authentication cookie is valid, based on the configured timeout value. We recommend that if you configure requireSSL as false, you also configure slidingExpiration as false, to reduce the amount of time for which a ticket is valid.

提交回复
热议问题