A fork of ResponseCachingMiddleware which provides more flexibility. Note that it uses official aspnetcore code directly (via git submodules and csproj linking).
Usage is similar to ResponseCachingMiddleware. Set the ResponseCachingStrategy to ResponseCachingStrategy.Distributed when calling AddResponseCaching and replace UseResponseCaching with UseCustomResponseCaching.
It will use whatever implementation of IDistributedCache that is injected into it.
public void ConfigureServices(IServiceCollection services)
{
services.AddResponseCaching(options =>
{
options.ResponseCachingStrategy = ResponseCachingStrategy.Distributed;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCustomResponseCaching();
}
This is a wrapper around DistributedResponseCache which allows you to easily exert some basic control over the underlying IDistributedCache. You can use your own custom logic to force the cache to clear, or to just ignore it.
To use, set the ResponseCachingStrategy to ResponseCachingStrategy.ModifiableDistributed and call UseCustomResponseCaching().
And inject IModifiableCacheController into the service provider.