ResponseCacheAttribute Class

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

Namespace
Microsoft.AspNetCore.Mvc
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ResponseCacheAttribute : Attribute, _Attribute, IFilterFactory, IOrderedFilter, IFilterMetadata
class Microsoft.AspNetCore.Mvc.ResponseCacheAttribute

Properties

Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.CacheProfileName

Gets or sets the value of the cache profile name.

Return type:System.String
public string CacheProfileName { get; set; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.Duration

Gets or sets the duration in seconds for which the response is cached. This sets “max-age” in “Cache-control” header.

Return type:System.Int32
public int Duration { get; set; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.IsReusable
Return type:System.Boolean
public bool IsReusable { get; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.Location

Gets or sets the location where the data from a particular URL must be cached.

Return type:Microsoft.AspNetCore.Mvc.ResponseCacheLocation
public ResponseCacheLocation Location { get; set; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.NoStore

Gets or sets the value which determines whether the data should be stored or not. When set to <xref uid=”langword_csharp_true” name=”true” href=”“></xref>, it sets “Cache-control” header to “no-store”. Ignores the “Location” parameter for values other than “None”. Ignores the “duration” parameter.

Return type:System.Boolean
public bool NoStore { get; set; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.Order
Return type:System.Int32
public int Order { get; set; }
Microsoft.AspNetCore.Mvc.ResponseCacheAttribute.VaryByHeader

Gets or sets the value for the Vary response header.

Return type:System.String
public string VaryByHeader { get; set; }

Methods

CreateInstance(System.IServiceProvider)
Return type:Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)