Skip to content

V11 P3 Update: Zstandard response compression added to response-compression.md #36992

@wadepickett

Description

@wadepickett

Description

zstd support was added in dotnet/aspnetcore#65479 for 11.0-preview3
See also parent tracking issue: #36990
See PR #36991 introduces the following new feature for ASP.NET Core in .NET 11 Preview 3:

Zstandard (zstd) response compression and request decompression: built-in support for the zstd algorithm in both the Response Compression Middleware and Request Decompression Middleware.

This is the primary reference article for response compression. The supported-encodings table is what developers consult to know which Accept-Encoding values the middleware handles. Zstandard is now a default compression provider alongside Brotli and Gzip, and its omission from this article would cause developers to miss a major built-in capability or try to implement it as a custom provider unnecessarily.

Also see related #36993 for request decompression.

Suggested changes:

  1. Update the Accept-Encoding table (around line 47) — Add zstd as a new supported encoding:
| [`Accept-Encoding`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Accept-Encoding) header values | Middleware Supported | Description |
| ------------------------------- | :------------------: | ----------- |
| `br`                            | Yes (default)        | [Brotli compressed data format](https://tools.ietf.org/html/rfc7932) |
| `deflate`                       | No                   | [DEFLATE compressed data format](https://tools.ietf.org/html/rfc1951) |
| `exi`                           | No                   | [W3C Efficient XML Interchange](https://www.w3.org/TR/exi/) |
| `gzip`                          | Yes                  | [Gzip file format](https://tools.ietf.org/html/rfc1952) |
| `identity`                      | Yes                  | "No encoding" identifier: The response must not be encoded. |
| `pack200-gzip`                  | No                   | [Network Transfer Format for Java Archives](https://jcp.org/aboutJava/communityprocess/review/jsr200/index.html) |
| `zstd`                          | Yes (default)        | [Zstandard compressed data format](https://facebook.github.io/zstd/) |
| `*`                             | Yes                  | Any available content encoding not explicitly requested |

2. Add a new "Zstandard compression provider" section (after line 113)

Insert after the "Brotli and Gzip compression providers" heading:

### Zstandard compression provider

:::moniker range=">= aspnetcore-11.0"

Use the `ZstandardCompressionProvider` to compress responses with the [Zstandard (zstd) compressed data format](https://facebook.github.io/zstd/).

If [no compression providers are explicitly added](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/ResponseCompression/src/ResponseCompressionProvider.cs#L44) to the <xref:Microsoft.AspNetCore.ResponseCompression.CompressionProviderCollection>, the Zstandard compression provider is included by default alongside Brotli and Gzip.

Set the compression quality with `ZstandardCompressionProviderOptions`:

```csharp
builder.Services.Configure<ZstandardCompressionProviderOptions>(options =>
{
    options.CompressionOptions = new ZstandardCompressionOptions
    {
        Quality = 6 // 1-22, higher = better compression, slower
    };
});

:::moniker-end


#### 3. Update the default providers description (lines 109–112)

Update to mention Zstandard:

```markdown
* The Brotli compression provider, Gzip compression provider, and Zstandard compression provider are added by default to the array of compression providers.
* Compression defaults to Brotli compression when the Brotli compressed data format is supported by the client. If Brotli isn't supported by the client, compression defaults to Zstandard when the client supports zstd, then falls back to Gzip when the client supports gzip.

4. Update the Troubleshooting section (line 172)

Include zstd:

* The `Accept-Encoding` header is present with a value of `br`, `gzip`, `zstd`, `*`, or custom encoding that matches a custom compression provider. The value must not be `identity` or have a quality value (qvalue, `q`) of 0 (zero).

Page URL

https://learn.microsoft.com/en-us/aspnet/core/performance/response-compression?view=aspnetcore-10.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/performance/response-compression.md

Document ID

2d56d9b6-3d7b-0204-6c08-8e584fccecc2

Platform Id

55d376a1-c786-a9cb-6de0-41ce7e32584f

Article author

@tdykstra

Metadata

  • ID: 9795b92f-db24-8f1f-88c0-c36666d3526f
  • PlatformId: 55d376a1-c786-a9cb-6de0-41ce7e32584f
  • Service: aspnet-core
  • Sub-service: performance

Related Issues


Associated WorkItem - 569848

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions