IL.RulesBasedOutputCache
1.0.19
See the version list below for details.
dotnet add package IL.RulesBasedOutputCache --version 1.0.19
NuGet\Install-Package IL.RulesBasedOutputCache -Version 1.0.19
<PackageReference Include="IL.RulesBasedOutputCache" Version="1.0.19" />
paket add IL.RulesBasedOutputCache --version 1.0.19
#r "nuget: IL.RulesBasedOutputCache, 1.0.19"
// Install IL.RulesBasedOutputCache as a Cake Addin #addin nuget:?package=IL.RulesBasedOutputCache&version=1.0.19 // Install IL.RulesBasedOutputCache as a Cake Tool #tool nuget:?package=IL.RulesBasedOutputCache&version=1.0.19
Output cache middleware
- Rules based output cache middleware - inspired by Microsoft output cache
Setup
v5 startup files structure (Program.cs and Startup.cs files)
ConfigureServices(IServiceCollection services)
services.AddRulesBasedOutputCache();
...
app.UseRulesBasedOutputCache();
v6+ startup files structure (Single Progam.cs file)
var builder = WebApplication.CreateBuilder(args);
builder.AddRulesBasedOutputCache();
...
var app = builder.Build();
app.UseRulesBasedOutputCache();
Tags management
In order to tag cache entries there are few extension methods available (IL.RulesBasedOutputCache.Helpers
namespace):
void ApplyCustomOutputCacheTagToCurrentRequest(this HttpContext context, string tag)
void ApplyCustomOutputCacheTagsToCurrentRequest(this HttpContext context, HashSet<string> tags)
void IgnoreRulesBasedOutputCacheForCurrentRequest(this HttpContext context)
which you can use to apply one or multiple tags to current request/potential cache entry.
Tags can be used for cache invalidation.
Cache invalidation
As library heavily relies on microsoft implementation of output cache you can use IOutputCacheStore
for eviction of cached entries by their tags.
await _store.EvictByTagAsync("CacheTag", HttpContext.RequestAborted);
Extra configurations
.AddRulesBasedOutputCache()
has optional parameter for inline service configuration.
Another invariant is providing configuration from appsettings.json
file.
Library comes with schema file, that you will be able to select as schema in your own appsettings.json
file.
Configuration parameters:
- OutputCacheEnabled - allows to disable module completely
- DefaultCacheTimeout - default expiration time for your cache entries, if not set up on the rule itself
- CachingRules - array of caching rules the system will have on application startup
- SqlConnectionStringName - optional string parameter, if provided will replace in-memory storage for rules with SQL based. You need to provide only the NAME of connection string, not the connection string itself. Database and/or required table will br created automatically, all the needed migrations will be automatically applied with new versions of library.
- OutputCacheAdminPanelEnabled - enables Admin panel api and access to admin panel page, which is available by url
/rulesBasedCache/adminPanel
Caching rule parameters:
- RuleTemplate - template to be matched in order for rule to become active. Examples:
/test
forExactPath
match rule/test/*
forRegex
match rule.js
forFileExtension
match rule. Also supports pipe separated list: '.js|.css|.html|.png'
- RuleAction -
Allow
orDissalow
- RuleType -
ExactPath
,Regex
orFileExtension
- VaryByQueryString - includes query string to cache key
- VaryByUser - includes HttpContext.User.Identity.Name to cache key
- VaryByHost - includes host string to cache key
- VaryByCulture - includes both CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture to cache key
- ResponseExpirationTimeSpan - specific expiration time for rule. TimeSpan format ("00:00:00")
Rules order
Rules have enforced order based on their RuleAction
and RuleType
. <br/>
Main ordering parameter is RuleAction
where Dissallow
has more priority than Allow
. <br/>
Then rules are ordered by RuleType
where priority goes as follows(low to high): FileExtension
, ExactPath
, Regex
. <br/>
Only rule with highest priority will be resolved per request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- IL.Misc (>= 1.1.0)
- Microsoft.EntityFrameworkCore (>= 7.0.11)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.11)
- Microsoft.EntityFrameworkCore.Tools (>= 7.0.11)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Options (>= 7.0.1)
-
net8.0
- IL.Misc (>= 1.1.0)
- Microsoft.EntityFrameworkCore (>= 8.0.4)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.4)
- Microsoft.EntityFrameworkCore.Tools (>= 8.0.4)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.3 | 231 | 7/15/2024 |
1.1.2 | 138 | 7/10/2024 |
1.1.1 | 72 | 7/9/2024 |
1.1.0 | 58 | 7/9/2024 |
1.0.19 | 215 | 5/13/2024 |
1.0.18 | 113 | 5/8/2024 |
1.0.17 | 247 | 10/22/2023 |
1.0.15 | 139 | 10/4/2023 |
1.0.9 | 122 | 9/23/2023 |
1.0.4 | 95 | 9/22/2023 |
1.0.3 | 129 | 9/21/2023 |
1.0.2 | 109 | 9/21/2023 |
1.0.1 | 114 | 9/21/2023 |
1.0.0 | 97 | 9/21/2023 |