caching 項目 (ASP.NET 設定結構描述)

設定 Web 應用程式的快取設定。

<caching>
   <cache>...</cache>
   <outputCache>...</outputCache>
   <outputCacheSettings>...</outputCacheSettings>
   <sqlCacheDependency>...</sqlCacheDependency>
</caching>

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

無。

子項目

項目

說明

Cache

選擇性項目。

定義全域應用程式快取設定。

outputCache

選擇性項目。

指定整個應用程式的輸出快取設定。

outputCacheSettings

選擇性項目。

指定可套用至應用程式中頁面的輸出快取設定。

sqlCacheDependency

選擇性項目。

設定 ASP.NET 應用程式的 SQL 快取相依性。

父項目

項目

說明

configuration

Common Language Runtime 和 .NET Framework 應用程式所使用之每一個組態檔中的必要根項目。

System.web

針對組態檔中的 ASP.NET 組態設定指定根項目。 包含設定 ASP.NET Web 應用程式和控制該應用程式行為方式的組態項目。

備註

預設的組態

下列預設 caching 項目沒有在 Machine.config 檔或根目錄 Web.config 檔中明確設定,但它卻是 .NET Framework 2.0 版中應用程式所傳回的預設組態。

<caching>
  <cache disableMemoryCollection = "false" 
    disableExpiration = "false" 
    privateBytesLimit = "0" 
    percentagePhysicalMemoryUsedLimit = "90" 
    privateBytesPollTime = "00:02:00"/>

  <outputCache enableOutputCache = "true" 
    enableFragmentCache = "true" 
    sendCacheControlHeader = "true" 
    omitVaryStar = "false" >
  </outputCache>

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

  <sqlCacheDependency enabled = "true" 
    pollTime = "60000">
    <databases>
       <clear />
      <add name = "" 
        connectionStringName = "" 
        pollTime = "60000"/>
    </databases>
  </sqlCacheDependency>

</caching>

範例

下列範例只花一分鐘快取伺服器上的頁面,並根據瀏覽器類型和主要版本儲存不同版本的頁面。

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

在設計需要以這種方式快取的頁面時,您將需要對頁面加入下列指示詞:

<%@ OutputCache CacheProfile="ServerOnly" %>

如需詳細資訊,請參閱@ OutputCache

項目資訊

組態區段處理常式

System.Web.Configuration.CacheSection

System.Web.Configuration.OutputCacheSection

System.Web.Configuration.OutputCacheSettingsSection

System.Web.Configuration.SqlCacheDependencySection

組態成員

System.Web.Configuration.SystemWebCachingSectionGroup

可設定的位置

Machine.config

根層次 Web.config

應用程式層級 Web.config

需求

IIS 5.0、5.1 和 6.0

.NET Framework 2.0

Visual Studio 2005

請參閱

工作

HOW TO:使用位置設定來設定特定的目錄

HOW TO:鎖定 ASP.NET 組態設定

參考

system.web 項目 (ASP.NET 設定結構描述)

configuration 項目 (一般設定結構描述)

caching 的 cache 項目 (ASP.NET 設定結構描述)

快取的 outputCache 項目 (ASP.NET 設定結構描述)

快取的 outputCacheSettings 項目 (ASP.NET 設定結構描述)

快取的 sqlCacheDependency 項目 (ASP.NET 設定結構描述)

System.Configuration

System.Web.Configuration

概念

ASP.NET 快取概觀

ASP.NET 組態檔階層架構和繼承

保護 ASP.NET 組態

ASP.NET 組態案例

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

ASP.NET 網站管理

ASP.NET 組態檔

ASP.NET 組態 API