BetterCache.Extensions 2026.1.1

dotnet add package BetterCache.Extensions --version 2026.1.1
                    
NuGet\Install-Package BetterCache.Extensions -Version 2026.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BetterCache.Extensions" Version="2026.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BetterCache.Extensions" Version="2026.1.1" />
                    
Directory.Packages.props
<PackageReference Include="BetterCache.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BetterCache.Extensions --version 2026.1.1
                    
#r "nuget: BetterCache.Extensions, 2026.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BetterCache.Extensions@2026.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BetterCache.Extensions&version=2026.1.1
                    
Install as a Cake Addin
#tool nuget:?package=BetterCache.Extensions&version=2026.1.1
                    
Install as a Cake Tool

BetterCache

Bring .NET 10 Blazor cache optimizations to .NET 9 projects via a single NuGet package: fingerprinting, pre-compression (Brotli/Gzip), preload hints, and aggressive immutable HTTP cache headers.

What it does

  • Immutable cache headers for fingerprinted _framework/* assets (1-year max-age, immutable), with must-revalidate on blazor.boot.json.
  • Pre-compressed static file serving — rewrites requests to .br / .gz siblings when the client supports the encoding.
  • MSBuild CompressAssets task — produces .br / .gz siblings at build time using System.IO.Compression.BrotliStream (no external brotli.exe dependency). No-op on assets the Blazor WebAssembly SDK already compresses; covers Blazor Server apps and custom static assets.
  • Preload hints — optional inline script that fetches blazor.boot.json client-side and emits <link rel="preload"> tags with the real fingerprinted URLs, avoiding the "preloaded but not used" warning.

Install

Published to nuget.org and GitHub Packages.

nuget.org (default)

dotnet add package BetterCache.Extensions

GitHub Packages (mirror)

dotnet nuget add source \
  --username <your-github-user> \
  --password <YOUR_GITHUB_PAT> \
  --store-password-in-clear-text \
  --name github \
  "https://nuget.pkg.github.com/massimopaganigh/index.json"

dotnet add package BetterCache.Extensions --source github

The PAT needs the read:packages scope (and write:packages to publish).

MSBuild props/targets auto-import via the NuGet build/ convention.

Publish

Tagged pushes (v*) trigger .github/workflows/publish.yml, which packs BetterCache.Extensions and pushes to both feeds:

Manual publish:

dotnet pack BetterCache/BetterCache.Extensions/BetterCache.Extensions.csproj -c Release -o ./artifacts
dotnet nuget push "./artifacts/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key <NUGET_API_KEY> --skip-duplicate
dotnet nuget push "./artifacts/*.nupkg" --source github --skip-duplicate

Usage

Program.cs:

using BetterCache;

builder.Services.AddBetterCache(options =>
{
    options.EnablePreloadHints = true;
    options.PreloadFrameworkFromBootManifest = true;
});

var app = builder.Build();

app.UseBetterCache(); // before MapStaticAssets
app.MapStaticAssets();

Head of your root layout:

@using BetterCache
<BetterCachePreload />

Options (BetterCacheOptions)

Property Default Purpose
ImmutableMaxAgeSeconds 31536000 max-age for fingerprinted framework assets.
FrameworkPathSegment /_framework/ Path segment that identifies framework assets.
BootManifestFileName blazor.boot.json Always revalidated.
ServePrecompressedAssets true Serve .br / .gz siblings.
EnablePreloadHints false Emit <link rel="preload"> tags.
PreloadAssets [] Static preload entries (use only for fingerprint-stable URLs).
PreloadFrameworkFromBootManifest false Inject inline script to preload fingerprinted framework assets.
BootManifestPath _framework/blazor.boot.json Relative to base href.

Projects

  • BetterCache.Extensions (net9.0) — runtime library: middleware, extensions, BetterCachePreload component, build/*.props|targets.
  • BetterCache.Extensions.Tasks (net8.0) — MSBuild CompressAssets task assembly.
  • BetterCache — sample Blazor Web App consumer.
  • BetterCache.Client — sample Blazor WebAssembly client.

Notes

  • Do not preload _framework/dotnet.runtime.js or _framework/dotnet.native.wasm with static URLs in .NET 9 — they are fingerprinted (dotnet.runtime.<hash>.js) and the URL will not match the real fetch. Use PreloadFrameworkFromBootManifest instead.
  • ProjectReference consumers must explicitly <Import> the build/*.props|targets files — auto-import only applies via NuGet.
  • PackageId is BetterCache.Extensions, not BetterCache, to avoid a NuGet restore collision with the sample project name.

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

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
2026.1.1 94 5/13/2026
2026.1.0 106 4/21/2026