ResponseExtensions.OutputCache Method
Configures the cache policy of an HTTP response instance.
Namespace: System.Web.WebPages
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Sub OutputCache ( _
response As HttpResponseBase, _
numberOfSeconds As Integer, _
sliding As Boolean, _
varyByParams As IEnumerable(Of String), _
varyByHeaders As IEnumerable(Of String), _
varyByContentEncodings As IEnumerable(Of String), _
cacheability As HttpCacheability _
)
'Usage
Dim response As HttpResponseBase
Dim numberOfSeconds As Integer
Dim sliding As Boolean
Dim varyByParams As IEnumerable(Of String)
Dim varyByHeaders As IEnumerable(Of String)
Dim varyByContentEncodings As IEnumerable(Of String)
Dim cacheability As HttpCacheability
response.OutputCache(numberOfSeconds, _
sliding, varyByParams, varyByHeaders, _
varyByContentEncodings, cacheability)
public static void OutputCache(
this HttpResponseBase response,
int numberOfSeconds,
bool sliding,
IEnumerable<string> varyByParams,
IEnumerable<string> varyByHeaders,
IEnumerable<string> varyByContentEncodings,
HttpCacheability cacheability
)
[ExtensionAttribute]
public:
static void OutputCache(
HttpResponseBase^ response,
int numberOfSeconds,
bool sliding,
IEnumerable<String^>^ varyByParams,
IEnumerable<String^>^ varyByHeaders,
IEnumerable<String^>^ varyByContentEncodings,
HttpCacheability cacheability
)
static member OutputCache :
response:HttpResponseBase *
numberOfSeconds:int *
sliding:bool *
varyByParams:IEnumerable<string> *
varyByHeaders:IEnumerable<string> *
varyByContentEncodings:IEnumerable<string> *
cacheability:HttpCacheability -> unit
public static function OutputCache(
response : HttpResponseBase,
numberOfSeconds : int,
sliding : boolean,
varyByParams : IEnumerable<String>,
varyByHeaders : IEnumerable<String>,
varyByContentEncodings : IEnumerable<String>,
cacheability : HttpCacheability
)
Parameters
- response
Type: System.Web.HttpResponseBase
The HTTP response instance.
- numberOfSeconds
Type: System.Int32
The length of time, in seconds, before items expire from the cache.
- sliding
Type: System.Boolean
true to indicate that items expire from the cache on a sliding basis; false to indicate that items expire when they reach the predefined expiration time.
- varyByParams
Type: System.Collections.Generic.IEnumerable<String>
The list of all parameters that can be received by a GET or POST operation that affect caching.
- varyByHeaders
Type: System.Collections.Generic.IEnumerable<String>
The list of all HTTP headers that affect caching.
- varyByContentEncodings
Type: System.Collections.Generic.IEnumerable<String>
The list of all Content-Encoding headers that affect caching.
- cacheability
Type: System.Web.HttpCacheability
One of the enumeration values that specifies how items are cached.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type HttpResponseBase. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=vs.111) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.111).
Remarks
When sliding is true, an item remains in the cache for the period specified in numberOfSeconds seconds after it was most recently accessed. When sliding is false, an item remains in the cache for the period specified in numberOfSeconds seconds after it was inserted in the cache, regardless of when the item was last accessed.