.NET Framework 类库
HttpResponse..::.Cache 属性

更新:2007 年 11 月

获取网页的缓存策略(例如:过期时间、保密性设置和变化条款)。

命名空间:  System.Web
程序集:  System.Web(在 System.Web.dll 中)

语法

Visual Basic(声明)
Public ReadOnly Property Cache As HttpCachePolicy
Visual Basic (用法)
Dim instance As HttpResponse
Dim value As HttpCachePolicy

value = instance.Cache
C#
public HttpCachePolicy Cache { get; }
Visual C++
public:
property HttpCachePolicy^ Cache {
    HttpCachePolicy^ get ();
}
J#
/** @property */
public HttpCachePolicy get_Cache()
JScript
public function get Cache () : HttpCachePolicy

属性值

类型:System.Web..::.HttpCachePolicy

包含与当前响应的缓存策略有关的信息的 HttpCachePolicy 对象。

示例

下面的示例将当前缓存策略的属性写入 HTTP 输出流。

Visual Basic
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(False)
Response.Cache.VaryByParams("Category") = True

If Response.Cache.VaryByParams("Category") Then
   '...
End If

C#
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(false);
Response.Cache.VaryByParams["Category"] = true;

if (Response.Cache.VaryByParams["Category"])
{
   //...
}
J#
get_Response().get_Cache().SetExpires(DateTime.get_Now().
    AddSeconds(60));
get_Response().get_Cache().SetCacheability(HttpCacheability.Public);
get_Response().get_Cache().SetValidUntilExpires(false);
get_Response().get_Cache().get_VaryByParams().
    set_Item("Category", true);

if (get_Response().get_Cache().get_VaryByParams().
    get_Item("Category")) {
    //...
}
JScript
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(false)
Response.Cache.VaryByParams("Category") = true

if(Response.Cache.VaryByParams("Category")){
   //...
}

平台

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.5、3.0、2.0、1.1、1.0
另请参见

参考

标记 :


Page view tracker