Ogu.AspNetCore.Compressions 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ogu.AspNetCore.Compressions --version 2.0.0
                    
NuGet\Install-Package Ogu.AspNetCore.Compressions -Version 2.0.0
                    
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="Ogu.AspNetCore.Compressions" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ogu.AspNetCore.Compressions" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Ogu.AspNetCore.Compressions" />
                    
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 Ogu.AspNetCore.Compressions --version 2.0.0
                    
#r "nuget: Ogu.AspNetCore.Compressions, 2.0.0"
                    
#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.
#addin nuget:?package=Ogu.AspNetCore.Compressions&version=2.0.0
                    
Install Ogu.AspNetCore.Compressions as a Cake Addin
#tool nuget:?package=Ogu.AspNetCore.Compressions&version=2.0.0
                    
Install Ogu.AspNetCore.Compressions as a Cake Tool

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.

[!NOTE]
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.

[!IMPORTANT]
Middleware must be registered in the correct order.
For more details, refer to the official middleware documentation.

Links:

Product 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. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.0 27 4/30/2025
2.0.2 42 4/27/2025
2.0.1 46 4/26/2025
2.0.0 38 4/26/2025
1.0.6 157 4/21/2025
1.0.5 113 4/6/2025
1.0.4 103 4/5/2025
1.0.3 161 3/8/2025
1.0.2 95 2/20/2025
1.0.1 91 1/12/2025
1.0.0 121 8/7/2024