caching 的 outputCacheProfiles 的 add 元素(ASP.NET 设置架构)

更新:2007 年 11 月

向配置集合添加一个 OutputCacheProfile 对象。只能通过页的 @ OutputCache 指令引用缓存配置文件。用户控件或服务器控件上不支持配置文件。

configuration 元素(常规设置架构)
  system.web 元素(ASP.NET 设置架构)
    caching 元素(ASP.NET 设置架构)
      caching 的 outputCacheSettings 元素(ASP.NET 设置架构)
        caching 的 outputCacheSettings 的 outputCacheProfiles 元素(ASP.NET 设置架构)
          caching 的 outputCacheProfiles 的 add 元素(ASP.NET 设置架构)

<add name="String" 
     enabled="true|false" 
     duration="number" 
     location="Any|Client|Downstream|Server|None|ServerAndClient" 
     sqlDependency="String" 
     varyByCustom="String" 
     varyByControl="String" 
     varyByHeader="String" 
     varyByParam="String" 
     noStore="true|false" />

属性和元素

以下几节描述了属性、子元素和父元素。

属性

属性

说明

name

必需的 String 属性。

设置缓存配置文件的唯一名称。

enabled

可选的 Boolean 属性。

为配置文件启用输出缓存。

duration

可选的 TimeSpan 属性。

设置在缓存中存储页的时间量(以秒计算)。

location

可选的 Int32 属性。

确定允许存储缓存响应的位置。

sqlDependency

可选的 String 属性。

设置页级别的 SQL 缓存依赖项。

varyByCustom

可选的 String 属性。

设置在为页调用 varyByCustom 时使用的字符串。

varyByControl

可选的 String 属性。

设置在调用 varyByControl 时缓存并使用的控件的 ID。也可以设置为以分号分隔的 ID 列表。

varyByHeader

可选的 String 属性。

为用于改变缓存输出的一组以分号分隔的标题进行命名。

varyByParam

可选的 String 属性。

为用于改变缓存输出的一组以分号分隔的参数进行命名。

noStore

可选的 Boolean 属性。

设置一个值,该值指示是否为响应缓存页而发送了“Cache-Control: no-store”指令。

子元素

无。

父元素

元素

说明

configuration

公共语言运行库和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。

system.web

指定配置文件中 ASP.NET 配置设置的根元素。包含各种配置元素,这些配置元素配置 ASP.NET Web 应用程序并控制这些应用程序的行为方式。

caching

为 Web 应用程序配置缓存设置。

outputCacheSettings

指定可以应用于 ASP.NET 应用程序中页的输出缓存设置。

outputCacheProfiles

包含可以应用于页以指定 OutputCache 指令的缓存设置组。

备注

默认配置

下面的默认 add 元素不是在计算机配置文件或根 Web.config 文件中显式配置的,而是由 .NET Framework 版本 2.0 中的应用程序返回的默认配置。

<add name = "" 
  enabled = "true" 
  duration = "-1" 
  location = "" 
  sqlDependency = "" 
  varyByCustom = "" 
  varyByControl = "" 
  varyByHeader = "" 
  varyByParam = "" 
  noStore = "false"/>

示例

下面的示例将某一页在服务器上仅缓存一分钟,并且根据浏览器类型和主版本存储该页的不同版本。

<outputCacheSettings>
  <outputCacheProfiles>
    <add name="ServerOnly" 
         duration="60" 
         varyByCustom="browser" 
         location="Server" />
  </outputCacheProfiles>
</outputCacheSettings>

设计需要以这种方式缓存的页时,您需要向该页添加以下指令:

<%@ OutputCache CacheProfile="ServerOnly" %>

有关更多信息,请参见 @ OutputCache

元素信息

配置节处理程序

System.Web.Configuration.OutputCacheSettingsSection

配置成员

OutputCacheSettingsSection.OutputCacheProfiles

可配置的位置

Machine.config

根级别的 Web.config

应用程序级别的 Web.config

要求

IIS 版本 5.0、5.1 和 6.0

.NET Framework 版本 2.0

Visual Studio 2005

请参见

任务

演练:使用输出缓存增强网站性能

如何:使用位置设置配置特定目录

如何:锁定 ASP.NET 配置设置

概念

ASP.NET 缓存概述

ASP.NET 配置文件层次结构和继承

保证 ASP.NET 配置的安全

ASP.NET 配置方案

参考

system.web 元素(ASP.NET 设置架构)

configuration 元素(常规设置架构)

caching 元素(ASP.NET 设置架构)

caching 的 outputCacheSettings 元素(ASP.NET 设置架构)

caching 的 outputCacheSettings 的 outputCacheProfiles 元素(ASP.NET 设置架构)

System.Configuration

System.Web.Configuration

其他资源

常规配置设置 (ASP.NET)

ASP.NET 配置设置

管理 ASP.NET 网站

ASP.NET 配置文件

ASP.NET 配置 API