OutputCacheAttribute Class

Definition

Specifies the parameters necessary for setting appropriate headers in output caching.

C#
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=false, Inherited=true)]
public sealed class OutputCacheAttribute : Attribute
Inheritance
OutputCacheAttribute
Attributes

Remarks

This attribute requires the output cache middleware.

Constructors

Properties

Duration

Gets or sets the duration in seconds for which the response is cached.

NoStore

Gets or sets the value which determines whether the response should be cached or not. When set to true, the response won't be cached.

PolicyName

Gets or sets the value of the cache policy name.

Tags

Gets or sets tags to apply to the output cache.

VaryByHeaderNames

Gets or sets the header names to vary by.

VaryByQueryKeys

Gets or sets the query keys to vary by.

VaryByRouteValueNames

Gets or sets the route value names to vary by.

Applies to

Product Versions
ASP.NET Core 7.0, 8.0, 9.0