Table of Contents

HttpCacheableOptions Class

Definition

Specifies options that is related to the HttpCacheableFilter.

public class HttpCacheableOptions : IValidatableParameterObject, IParameterObject
Inheritance
HttpCacheableOptions
Implements

Examples

The following example configures with a custom Cache-Control header and manually adds both cacheable filters used by .

// Program.cs
using System;
using Cuemon.AspNetCore.Mvc.Filters.Cacheable;
using Microsoft.Net.Http.Headers;

var options = new HttpCacheableOptions
{
    CacheControl = new CacheControlHeaderValue
    {
        MaxAge = TimeSpan.FromMinutes(15),
        Public = true,
        MustRevalidate = false
    }
};

options.Filters.Add(new HttpEntityTagHeaderFilter(o => o.UseEntityTagResponseParser = true));
options.Filters.Add(new HttpLastModifiedHeaderFilter());

Console.WriteLine(options.UseCacheControl);
Console.WriteLine(options.Filters.Count);
Console.WriteLine(options.CacheControl.MaxAge);

Constructors

Name Description
HttpCacheableOptions()

Initializes a new instance of the HttpCacheableOptions class.

Properties

Name Description
CacheControl

Gets or sets the Cache-Control header that is applied to objects implementing the ICacheableObjectResult interface.

Filters

Gets the filters that will be invoked one by one in OnResultExecutionAsync(ResultExecutingContext, ResultExecutionDelegate).

UseCacheControl

Gets a value indicating whether this instance has an CacheControl.

Methods

Name Description
ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.