Add CompressionLevel.SmallestSize and actual Gzip/Brotli compression levels (#31722)
* Document CompressionLevel.SmallestSize and actual Gzip/Brotli compression levels Since [.Net 6](pull/31835/head7d527c3368
) there has been an additional option: `CompressionLevel.SmallestSize`. And since .Net 7 `Optimal` was [fixed](f281393412
) to not mean smallest size anymore but rather a balanced value. This change is also documents what these abstracted `CompressionLevel` values means for Gzip and Brotli compression libraries, given those are enabled by default. In my case I came to this page wanting to get an Idea of balancing CPU use vs size of the response, as there are plenty of pages online benchmarking zlib vs brotli at all possible levels and cpu types. * Update aspnetcore/performance/response-compression.md * Update aspnetcore/performance/response-compression.md Co-authored-by: Tom Dykstra <tdykstra@microsoft.com> * Update aspnetcore/performance/response-compression.md --------- Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>
parent
af011a27bf
commit
de3a5b9a03
|
@ -125,11 +125,7 @@ The following code:
|
|||
|
||||
Set the compression level with <xref:Microsoft.AspNetCore.ResponseCompression.BrotliCompressionProviderOptions> and <xref:Microsoft.AspNetCore.ResponseCompression.GzipCompressionProviderOptions>. The Brotli and Gzip compression providers default to the fastest compression level, [CompressionLevel.Fastest](xref:System.IO.Compression.CompressionLevel), which might not produce the most efficient compression. If the most efficient compression is desired, configure the response compression middleware for optimal compression.
|
||||
|
||||
| Compression Level | Description |
|
||||
| ----------------- | ----------- |
|
||||
| [CompressionLevel.Fastest](xref:System.IO.Compression.CompressionLevel) | Compression should complete as quickly as possible, even if the resulting output isn't optimally compressed. |
|
||||
| [CompressionLevel.NoCompression](xref:System.IO.Compression.CompressionLevel) | No compression should be performed. |
|
||||
| [CompressionLevel.Optimal](xref:System.IO.Compression.CompressionLevel) | Responses should be optimally compressed, even if the compression takes more time to complete. |
|
||||
See [CompressionLevel Enum](/dotnet/api/system.io.compression.compressionlevel) for values that indicate whether a compression operation emphasizes speed or compression size.
|
||||
|
||||
[!code-csharp[](response-compression/samples/6.x/SampleApp/Program.cs?name=snippet2&highlight=13-21)]
|
||||
|
||||
|
|
Loading…
Reference in New Issue