HttpCachePolicy.SetSlidingExpiration(Boolean) 方法

定义

将缓存过期从绝对时间设置为可调时间。Sets cache expiration to from absolute to sliding.

public:
 void SetSlidingExpiration(bool slide);
public void SetSlidingExpiration (bool slide);
member this.SetSlidingExpiration : bool -> unit
Public Sub SetSlidingExpiration (slide As Boolean)

参数

slide
Boolean

truefalsetrue or false.

示例

下面的代码示例演示如何将可调过期设置为 trueThe following code example demonstrates how to set sliding expiration to true.

Response.Cache.SetSlidingExpiration(true);

Response.Cache.SetSlidingExpiration(True)
    

注解

如果将 "缓存过期" 设置为 "滑动",则 Cache-Control 会随每个响应一起续订 HTTP 标头。When cache expiration is set to sliding, the Cache-Control HTTP header will be renewed with each response. 此过期模式与 IIS 配置选项相同,可将过期标头添加到相对于当前时间的所有输出集。This expiration mode is identical to the IIS configuration option to add an expiration header to all output set relative to the current time.

如果你将 "可调过期" 显式设置为 false "关闭" () ,则会保留该设置,并且任何启用可调过期的尝试都将失败。If you explicitly set sliding expiration to off (false), that setting will be preserved and any attempts to enable sliding expiration will silently fail. 此方法不会直接映射到 HTTP 标头。This method does not directly map to an HTTP header. 后面的模块或辅助角色请求使用它来设置源服务器缓存策略。It is used by subsequent modules or worker requests to set origin-server cache policy.

SetSlidingExpiration .NET Framework 版本3.5 中引入。SetSlidingExpiration is introduced in the .NET Framework version 3.5. 有关详细信息,请参见版本和依赖关系For more information, see Versions and Dependencies.

适用于