Ogu.AspNetCore.Compressions
2.1.2
dotnet add package Ogu.AspNetCore.Compressions --version 2.1.2
NuGet\Install-Package Ogu.AspNetCore.Compressions -Version 2.1.2
<PackageReference Include="Ogu.AspNetCore.Compressions" Version="2.1.2" />
<PackageVersion Include="Ogu.AspNetCore.Compressions" Version="2.1.2" />
<PackageReference Include="Ogu.AspNetCore.Compressions" />
paket add Ogu.AspNetCore.Compressions --version 2.1.2
#r "nuget: Ogu.AspNetCore.Compressions, 2.1.2"
#:package Ogu.AspNetCore.Compressions@2.1.2
#addin nuget:?package=Ogu.AspNetCore.Compressions&version=2.1.2
#tool nuget:?package=Ogu.AspNetCore.Compressions&version=2.1.2
Ogu.AspNetCore.Compressions
This library extends ASP.NET Core’s native compression capabilities with additional options not included in the core framework.
Packages Overview
| Package | Description |
|---|---|
| Ogu.AspNetCore.Compressions | Aggregates the ASP.NET Core-specific compression providers for Deflate, Snappy, and Zstd. |
| Ogu.AspNetCore.Compressions.Deflate | Provides a DeflateCompressionProvider for ASP.NET Core middleware with "deflate" encoding support. |
| Ogu.AspNetCore.Compressions.Snappy | Provides a SnappyCompressionProvider for ASP.NET Core middleware with "snappy" encoding support. |
| Ogu.AspNetCore.Compressions.Zstd | Provides a ZstdCompressionProvider for ASP.NET Core middleware with "zstd" encoding support. |
| Ogu.AspNetCore.Compression.Abstractions | Defines unified interfaces for the Ogu.AspNetCore.Compressions.* libraries. |
Usage
Changing provider options compression level:
services.Configure<BrotliCompressionProviderOptions>(opts =>
{
opts.Level = CompressionLevel.Fastest;
});
| Encoding Name | CompressionProviderOptions |
|---|---|
| brotli | BrotliCompressionProviderOptions |
| snappy | SnappyCompressionProviderOptions |
| zstandard | ZstdCompressionProviderOptions |
| gzip | GzipCompressionProviderOptions |
| deflate | DeflateCompressionProviderOptions |
Registering providers:
The server decides which compression provider to use based on the client's Accept-Encoding header. For example, if a client sends Accept-Encoding: gzip, br, zstd, the server will select the first supported encoding in the list.
In the example below, the server will respond using Brotli (br) compression because the BrotliCompressionProvider registered first with opts.Providers.Add<BrotliCompressionProvider>().
It is the caller’s responsibility to handle the response correctly.
The server includes the actual encoding used in the Content-Encoding header — in this case, it will be br.
services.AddResponseCompression(opts =>
{
opts.Providers.Add<BrotliCompressionProvider>();
opts.Providers.Add<ZstdCompressionProvider>();
opts.Providers.Add<GzipCompressionProvider>();
opts.Providers.Add<SnappyCompressionProvider>();
opts.Providers.Add<DeflateCompressionProvider>();
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes;
opts.EnableForHttps = true;
});
If the client requests encodings that the server does not support (e.g., Accept-Encoding: special), compression will not occur, and the response will be sent uncompressed.
opts.MimeTypes defines which response Content-Types are eligible for compression. In this example, it uses the defaults provided by ResponseCompressionDefaults.MimeTypes (e.g., text/plain, application/json, etc.).
Adding the Middleware
The last step is to add the response compression middleware to the pipeline, so it can automatically handle compression for outgoing responses.
app.UseResponseCompression();
Once added, the server will compress eligible responses based on the client’s Accept-Encoding header and the registered compression providers.
Middleware must be registered in the correct order.
For more details, refer to the official middleware documentation.
Links:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. 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. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
.NETStandard 2.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
.NETStandard 2.1
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
net5.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
net6.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
net7.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
net8.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
-
net9.0
- Ogu.AspNetCore.Compressions.Deflate (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Snappy (>= 2.1.2)
- Ogu.AspNetCore.Compressions.Zstd (>= 2.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.