Page.InitOutputCache Page.InitOutputCache Page.InitOutputCache Page.InitOutputCache Method

定義

為目前網頁要求初始化輸出快取。Initializes the output cache for the current page request.

多載

InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String)

為目前網頁要求初始化輸出快取。Initializes the output cache for the current page request.

InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String)

為目前網頁要求初始化輸出快取。Initializes the output cache for the current page request.

InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters)

根據 OutputCacheParameters 物件,初始化目前頁面要求的輸出快取。Initializes the output cache for the current page request based on an OutputCacheParameters object.

備註

這個方法不能從程式碼直接使用。This method is not intended to be used directly from your code. 若要啟用及動作頁面的輸出快取,請使用下列其中一種方法:To enable and manipulate output caching for a page, use one of these approaches:

  • 使用 .aspx 檔案中的指示詞,以宣告方式設定選項。Set options declaratively using the directive in the .aspx file.

  • 使用HttpCachePolicy類別的方法和屬性,它是由頁面的程式碼Response.Cache中的物件所公開。Use the methods and properties of the HttpCachePolicy class, which is exposed by the Response.Cache object in the page's code.

如需詳細資訊,請參閱快取ASP.NET 網頁For more information, see Caching ASP.NET Pages.

InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, OutputCacheLocation, String)

為目前網頁要求初始化輸出快取。Initializes the output cache for the current page request.

protected:
 virtual void InitOutputCache(int duration, System::String ^ varyByHeader, System::String ^ varyByCustom, System::Web::UI::OutputCacheLocation location, System::String ^ varyByParam);
protected virtual void InitOutputCache (int duration, string varyByHeader, string varyByCustom, System.Web.UI.OutputCacheLocation location, string varyByParam);
abstract member InitOutputCache : int * string * string * System.Web.UI.OutputCacheLocation * string -> unit
override this.InitOutputCache : int * string * string * System.Web.UI.OutputCacheLocation * string -> unit
Protected Overridable Sub InitOutputCache (duration As Integer, varyByHeader As String, varyByCustom As String, location As OutputCacheLocation, varyByParam As String)

參數

duration
Int32 Int32 Int32 Int32

儲存在輸出快取中的物件是有效的經過時間量。The amount of time that objects stored in the output cache are valid.

varyByHeader
String String String String

以分號分隔的標頭清單,輸出快取內容會因這個清單而有所不同。A semicolon-separated list of headers that content from the output cache will vary by.

varyByCustom
String String String String

Vary HTTP 標頭。The Vary HTTP header.

varyByParam
String String String String

GET 或 POST 方法接收的參數清單 (以分號分隔),輸出快取內容會因這個清單而有所不同。A semicolon-separated list of parameters received by a GET or POST method that content from the output cache will vary by.

例外狀況

location 指定的值無效。An invalid value is specified for location.

備註

您不應該呼叫這個方法。You should not call this method. 若要啟用和動作頁面的輸出快取,請使用 .aspx 檔案中的指示詞,或HttpCachePolicy類別的方法和屬性。To enable and manipulate output caching for a page, use either the directive in the .aspx file, or the methods and properties of the HttpCachePolicy class. 後者可透過Response.Cache頁面程式碼中的語法來存取。The latter are accessible through Response.Cache syntax in the page's code. 如需詳細資訊,請參閱快取ASP.NET 網頁For more information, see Caching ASP.NET Pages.

另請參閱

InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) InitOutputCache(Int32, String, String, String, OutputCacheLocation, String)

為目前網頁要求初始化輸出快取。Initializes the output cache for the current page request.

protected:
 virtual void InitOutputCache(int duration, System::String ^ varyByContentEncoding, System::String ^ varyByHeader, System::String ^ varyByCustom, System::Web::UI::OutputCacheLocation location, System::String ^ varyByParam);
protected virtual void InitOutputCache (int duration, string varyByContentEncoding, string varyByHeader, string varyByCustom, System.Web.UI.OutputCacheLocation location, string varyByParam);
abstract member InitOutputCache : int * string * string * string * System.Web.UI.OutputCacheLocation * string -> unit
override this.InitOutputCache : int * string * string * string * System.Web.UI.OutputCacheLocation * string -> unit
Protected Overridable Sub InitOutputCache (duration As Integer, varyByContentEncoding As String, varyByHeader As String, varyByCustom As String, location As OutputCacheLocation, varyByParam As String)

參數

duration
Int32 Int32 Int32 Int32

儲存在輸出快取中的物件是有效的經過時間量。The amount of time that objects stored in the output cache are valid.

varyByContentEncoding
String String String String

以分號分隔的字元集 (內容編碼) 清單,輸出快取內容會因這個清單而有所不同。A semicolon-separated list of character-sets (content encodings) that content from the output cache will vary by.

varyByHeader
String String String String

以分號分隔的標頭清單,輸出快取內容會因這個清單而有所不同。A semicolon-separated list of headers that content from the output cache will vary by.

varyByCustom
String String String String

Vary HTTP 標頭。The Vary HTTP header.

varyByParam
String String String String

GET 或 POST 方法接收的參數清單 (以分號分隔),輸出快取內容會因這個清單而有所不同。A semicolon-separated list of parameters received by a GET or POST method that content from the output cache will vary by.

例外狀況

location 指定的值無效。An invalid value is specified for location.

備註

您不應該呼叫這個方法。You should not call this method. 若要啟用和動作頁面的輸出快取,請使用 .aspx 檔案中的指示詞,或HttpCachePolicy類別的方法和屬性。To enable and manipulate output caching for a page, use either the directive in the .aspx file, or methods and properties of the HttpCachePolicy class. 後者可透過Response.Cache頁面程式碼中的語法來存取。The latter are accessible through Response.Cache syntax in the page's code. 如需詳細資訊,請參閱快取ASP.NET 網頁For more information, see Caching ASP.NET Pages.

另請參閱

InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters) InitOutputCache(OutputCacheParameters)

根據 OutputCacheParameters 物件,初始化目前頁面要求的輸出快取。Initializes the output cache for the current page request based on an OutputCacheParameters object.

protected public:
 virtual void InitOutputCache(System::Web::UI::OutputCacheParameters ^ cacheSettings);
protected internal virtual void InitOutputCache (System.Web.UI.OutputCacheParameters cacheSettings);
abstract member InitOutputCache : System.Web.UI.OutputCacheParameters -> unit
override this.InitOutputCache : System.Web.UI.OutputCacheParameters -> unit
Protected Friend Overridable Sub InitOutputCache (cacheSettings As OutputCacheParameters)

參數

例外狀況

找不到快取設定檔。The cache profile was not found.

-或--or-

遺漏指示詞或組態設定的設定檔屬性。A missing directive or configuration settings profile attribute.

輸出快取設定位置無效。The output cache settings location is invalid.

備註

您不應該呼叫這個方法。You should not call this method. 若要啟用和動作頁面的輸出快取,請使用 .aspx 檔案中的指示詞,或HttpCachePolicy類別的方法和屬性。To enable and manipulate output caching for a page, use either the directive in the .aspx file, or the methods and properties of the HttpCachePolicy class. 後者可透過Response.Cache頁面的程式碼宣告區塊或程式碼後置檔案中的語法來存取。The latter are accessible through Response.Cache syntax in the page's code declaration block or code-behind file. 如需詳細資訊,請參閱快取ASP.NET 網頁For more information, see Caching ASP.NET Pages.

另請參閱

適用於