Class CompressionSettings.Zstandard

java.lang.Object
com.iizix.jetty.CompressionSettings.Zstandard
Enclosing class:
CompressionSettings

public static final class CompressionSettings.Zstandard extends Object
Default settings for the Zstandard compression algorithm (ZstandardCompression).

Backed by the zstd-jni native library (bundled inside the jetty-compression-zstandard jar for the major platforms). Supported by Firefox 126+ (2024-05) and Chrome 123+ (2024-03).

Zstandard is generally faster than brotli at comparable compression ratios, and uniquely supports negative "fast" levels for ultra-low-CPU encoding. Defaults below favour ratio.

Author:
Christopher Mindus
  • Field Details

    • COMPRESSION_LEVEL

      public static volatile int COMPRESSION_LEVEL
      Zstandard compression level.

      Possible values are 1 through 19. The zstd library itself also has "fast" modes -7..-1 and "ultra" modes 20..22, but the Jetty wrapper exposes neither and raises IllegalArgumentException for anything outside 1..19, which disables zstandard for the whole server. Reference points:

      • 1..3 -- fast, typical for low-latency HTTP (level 3 is the zstd default)
      • 4..9 -- balanced
      • 10..19 -- slower, better ratio

      Default: 19 (maximum usable compression -- the same value as WSHelper.Type.ZSTANDARD.compressionLevel, and NOT the zstd maximum of 22, which the Jetty wrapper cannot take).

    • BUFFER_SIZE

      public static volatile int BUFFER_SIZE
      Encoder buffer size in bytes.

      Possible values: any positive int; practical range 8192..524288. Zstandard benefits from larger buffers than gzip or brotli, particularly at high compression levels where its window can extend into the megabyte range.

      Default: 65536 (64 KiB).