Table of Contents

Class HttpCacheableFilter

Namespace
Cuemon.AspNetCore.Mvc.Filters.Cacheable
Assembly
Cuemon.AspNetCore.Mvc.dll

A filter that will invoke filters implementing the ICacheableObjectResult interface.

public class HttpCacheableFilter : ConfigurableAsyncResultFilter<HttpCacheableOptions>, IConfigurable<HttpCacheableOptions>, IAsyncResultFilter, IFilterMetadata
Inheritance
HttpCacheableFilter
Implements
Inherited Members

Examples

The following example shows how to compose from packet-local options and cache validators.

using System;
using Cuemon.AspNetCore.Mvc.Filters.Cacheable;
using Microsoft.Extensions.Options;

namespace MyApp.Examples;

public static class HttpCacheableFilterExample
{
    public static void Demonstrate()
    {
        var options = new HttpCacheableOptions();
        options.Filters.Add(new HttpEntityTagHeaderFilter(io => io.UseEntityTagResponseParser = true));
        options.Filters.Add(new HttpLastModifiedHeaderFilter());

        var filter = new HttpCacheableFilter(Options.Create(options));

        Console.WriteLine(filter.Options.Filters.Count);
        Console.WriteLine(filter.Options.UseCacheControl);
    }
}

Constructors

HttpCacheableFilter(IOptions<HttpCacheableOptions>)

Initializes a new instance of the HttpCacheableFilter class.

public HttpCacheableFilter(IOptions<HttpCacheableOptions> setup)

Parameters

setup IOptions<HttpCacheableOptions>

The HttpCacheableOptions which need to be configured.

Methods

OnResultExecutionAsync(ResultExecutingContext, ResultExecutionDelegate)

Called asynchronously before the action result.

public override Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next)

Parameters

context ResultExecutingContext

The ResultExecutingContext.

next ResultExecutionDelegate

The ResultExecutionDelegate. Invoked to execute the next result filter or the result itself.

Returns

Task

A Task that on completion indicates the filter has executed.

See Also