Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
No response
Describe the solution you'd like
Zstandard, or zstd, is a data compression mechanism described in RFC8878. It is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. The "zstd" token was added as an IANA-registered Content-Encoding token as per https://datatracker.ietf.org/doc/html/rfc8878#name-content-encoding.
The Facebook/Zstd team has published some of their research on compression level vs. CPU vs. compression ratio.
Current support
Features request
Request compression
- Support
zstd as the token from the Content-Encoding header in the request.
- Decompress with Zstandard the request content.
Response compression
- Support
zstd as a token from the Accept-Encoding header in the request.
- Compress with Zstandard when the
zstd token is elected as response compression, and so stored in the Content-Encoding header in the response.
Zstandard implementation
API Proposal: Add Zstandard (zstd) Response Compression Support
Background and Motivation
ASP.NET Core currently supports Gzip and Brotli compression for HTTP request and responses through the Request Decompression and Response Compression middlewares.
Zstandard (zstd) is a modern, high-performance compression algorithm that offers:
- Better compression ratios than gzip at similar speeds
- Faster decompression than both gzip and brotli
- Wide industry adoption (supported by major browsers and CDNs)
- RFC 8878 standardization
With the recent addition of System.IO.Compression.ZstandardStream to the .NET runtime (available in .NET 11 Preview 1), ASP.NET Core can now natively support Zstd compression without external dependencies.
Adding Zstd support would provide developers with a modern compression option that balances compression ratio and performance.
Response compression
Proposed API
namespace Microsoft.AspNetCore.ResponseCompression;
public class ZstdCompressionProvider : ICompressionProvider
{
public ZstdCompressionProvider(IOptions<ZstdCompressionProviderOptions> options);
public string EncodingName { get; }
public bool SupportsFlush { get; }
public Stream CreateStream(Stream outputStream);
}
public class ZstdCompressionProviderOptions : IOptions<ZstdCompressionProviderOptions>
{
public CompressionLevel Level { get; set; }
ZstdCompressionProviderOptions IOptions<ZstdCompressionProviderOptions>.Value { get; }
}
Usage Examples
Basic Usage
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddResponseCompression(options =>
{
options.Providers.Add<ZstdCompressionProvider>();
});
var app = builder.Build();
app.UseResponseCompression();
app.Run();
Custom Compression Level
builder.Services.AddResponseCompression(options =>
{
options.Providers.Add<ZstdCompressionProvider>();
});
builder.Services.Configure<ZstdCompressionProviderOptions>(options =>
{
options.Level = CompressionLevel.Optimal;
});
Default Configuration
Zstd becomes the default first compression provider in the priority order: zstd → brotli → gzip
This means clients that support zstd (via Accept-Encoding: zstd) will automatically receive zstd-compressed responses without any additional configuration.
This also means clients that support multiple encodings (via Accept-Encoding: gzip, br, zstd) will automatically receive zstd-compressed responses by default.
Request decompression
zstd is added as a supported Content-Encoding value.
Usage examples
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRequestDecompression();
var app = builder.Build();
app.UseRequestDecompression();
app.MapPost("/", (HttpRequest request) => Results.Stream(request.Body));
app.Run();
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
No response
Describe the solution you'd like
Zstandard, or
zstd, is a data compression mechanism described in RFC8878. It is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. The "zstd" token was added as an IANA-registered Content-Encoding token as per https://datatracker.ietf.org/doc/html/rfc8878#name-content-encoding.The Facebook/Zstd team has published some of their research on compression level vs. CPU vs. compression ratio.
Current support
Features request
Request compression
zstdas the token from theContent-Encodingheader in the request.Response compression
zstdas a token from theAccept-Encodingheader in the request.zstdtoken is elected as response compression, and so stored in theContent-Encodingheader in the response.Zstandard implementation
API Proposal: Add Zstandard (zstd) Response Compression Support
Background and Motivation
ASP.NET Core currently supports Gzip and Brotli compression for HTTP request and responses through the Request Decompression and Response Compression middlewares.
Zstandard (zstd) is a modern, high-performance compression algorithm that offers:
With the recent addition of
System.IO.Compression.ZstandardStreamto the .NET runtime (available in .NET 11 Preview 1), ASP.NET Core can now natively support Zstd compression without external dependencies.Adding Zstd support would provide developers with a modern compression option that balances compression ratio and performance.
Response compression
Proposed API
Usage Examples
Basic Usage
Custom Compression Level
Default Configuration
Zstd becomes the default first compression provider in the priority order: zstd → brotli → gzip
This means clients that support zstd (via
Accept-Encoding: zstd) will automatically receive zstd-compressed responses without any additional configuration.This also means clients that support multiple encodings (via
Accept-Encoding: gzip, br, zstd) will automatically receive zstd-compressed responses by default.Request decompression
zstdis added as a supportedContent-Encodingvalue.Usage examples