Page.InitOutputCache Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes the output cache for the current page request.
Overloads
InitOutputCache(Int32, String, String, OutputCacheLocation, String) |
Initializes the output cache for the current page request. |
InitOutputCache(Int32, String, String, String, OutputCacheLocation, String) |
Initializes the output cache for the current page request. |
InitOutputCache(OutputCacheParameters) |
Initializes the output cache for the current page request based on an OutputCacheParameters object. |
Remarks
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:
- Set options declaratively using the
@ OutputCache
directive in the .aspx file. - Use the methods and properties of the HttpCachePolicy class, which is exposed by the
Response.Cache
object in the page's code.
For more information, see Caching ASP.NET Pages.
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)
Parameters
- duration
- Int32
The amount of time that objects stored in the output cache are valid.
- varyByHeader
- String
A semicolon-separated list of headers that content from the output cache will vary by.
- varyByCustom
- String
The Vary
HTTP header.
- location
- OutputCacheLocation
One of the OutputCacheLocation values.
- varyByParam
- String
A semicolon-separated list of parameters received by a GET or POST method that content from the output cache will vary by.
Exceptions
An invalid value is specified for location
.
Remarks
You should not call this method. To enable and manipulate output caching for a page, use either the @ OutputCache
directive in the .aspx file, or the methods and properties of the HttpCachePolicy class. The latter are accessible through Response.Cache
syntax in the page's code. For more information, see Caching ASP.NET Pages.
See also
Applies to
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)
Parameters
- duration
- Int32
The amount of time that objects stored in the output cache are valid.
- varyByContentEncoding
- String
A semicolon-separated list of character-sets (content encodings) that content from the output cache will vary by.
- varyByHeader
- String
A semicolon-separated list of headers that content from the output cache will vary by.
- varyByCustom
- String
The Vary
HTTP header.
- location
- OutputCacheLocation
One of the OutputCacheLocation values.
- varyByParam
- String
A semicolon-separated list of parameters received by a GET or POST method that content from the output cache will vary by.
Exceptions
An invalid value is specified for location
.
Remarks
You should not call this method. To enable and manipulate output caching for a page, use either the @ OutputCache
directive in the .aspx file, or methods and properties of the HttpCachePolicy class. The latter are accessible through Response.Cache
syntax in the page's code. For more information, see Caching ASP.NET Pages.
See also
Applies to
InitOutputCache(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)
Parameters
- cacheSettings
- OutputCacheParameters
An OutputCacheParameters that contains the cache settings.
Exceptions
The cache profile was not found.
-or-
A missing directive or configuration settings profile attribute.
The output cache settings location is invalid.
Remarks
You should not call this method. To enable and manipulate output caching for a page, use either the @ OutputCache
directive in the .aspx file, or the methods and properties of the HttpCachePolicy class. The latter are accessible through Response.Cache
syntax in the page's code declaration block or code-behind file. For more information, see Caching ASP.NET Pages.