ResponseCacheFilter Class

Summary

An [Microsoft.AspNet.Mvc.ActionFilterAttribute](Microsoft.AspNet.Mvc.ActionFilterAttribute.yml) which sets the appropriate headers related to response caching.

Syntax

public class ResponseCacheFilter : IResponseCacheFilter, IActionFilter, IFilter

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.ResponseCacheFilter

Constructors

ResponseCacheFilter(Microsoft.AspNet.Mvc.CacheProfile)

Creates a new instance of [Microsoft.AspNet.Mvc.ResponseCacheFilter](Microsoft.AspNet.Mvc.ResponseCacheFilter.yml)

Arguments:
  • cacheProfile (Microsoft.AspNet.Mvc.CacheProfile) – The profile which contains the settings for [Microsoft.AspNet.Mvc.ResponseCacheFilter](Microsoft.AspNet.Mvc.ResponseCacheFilter.yml).
public ResponseCacheFilter(CacheProfile cacheProfile)

Properties

Duration()

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

Return type:System.Int32
public int Duration { get; set; }
Location()

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

Return type:Microsoft.AspNet.Mvc.ResponseCacheLocation
public ResponseCacheLocation Location { get; set; }
NoStore()

Gets or sets the value which determines whether the data should be stored or not. When set to <see langword=”true” />, 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; }
VaryByHeader()

Gets or sets the value for the Vary response header.

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

Methods

OnActionExecuted(Microsoft.AspNet.Mvc.ActionExecutedContext)
Arguments:
public void OnActionExecuted(ActionExecutedContext context)
OnActionExecuting(Microsoft.AspNet.Mvc.ActionExecutingContext)
Arguments:
public void OnActionExecuting(ActionExecutingContext context)