Compression

Zstandard Compression

Meta's compression algorithm. Faster to decompress than brotli. We ship it.

nginx-module-zstd

Install

Make sure you have the official nginx.org repository configured first. These packages require nginx from nginx.org, not the distro-bundled version.

Add the Blendbyte repository if you haven't already:

Add Blendbyte repository
sudo install -d -m 0755 /etc/apt/keyrings

curl -fsSL https://apt.blendbyte.net/nginx/blendbyte-archive-keyring.gpg \
  | sudo tee /etc/apt/keyrings/blendbyte.gpg >/dev/null

echo "deb [signed-by=/etc/apt/keyrings/blendbyte.gpg] https://apt.blendbyte.net/nginx $(lsb_release -cs) main" \
  | sudo tee /etc/apt/sources.list.d/blendbyte.list

sudo apt update

Then install this module:

Install nginx-module-zstd
$ sudo apt install nginx-module-zstd

Most modules auto-enable on install. If yours didn't, enable it manually:

Enable module manually (if needed)
$ sudo ln -s /etc/nginx/modules-available/50-mod-zstd.conf \
  /etc/nginx/modules-enabled/
$ sudo nginx -t && sudo systemctl reload nginx

What it does

Zstandard was developed at Meta and open-sourced in 2016. It offers a compelling combination: compression ratios comparable to brotli, with significantly faster decompression on the client side. Browser support is growing. Chrome has it, Firefox does too, Safari is getting there. For large JSON payloads, binary content, or any scenario where decompression speed matters on the client, zstd is worth evaluating. We ship it now because that's when you want to start testing, not after browser support hits 95%. The module integrates with nginx's standard compression directive patterns.

When to use it

  • Compress large API responses with faster client-side decompression than brotli
  • Reduce time-to-parsed for large JSON payloads in web applications
  • Future-proof your compression stack as zstd browser support matures
  • Complement brotli and gzip with a third compression option based on Accept-Encoding

Configuration

A starting-point configuration. Adjust to your setup.

nginx.conf example
# Inside your http {} block:
zstd            on;
zstd_comp_level 3;
zstd_types
  text/html
  text/css
  application/javascript
  application/json;

# Use all three for maximum coverage
brotli on;
gzip   on;

Upstream project

This module is packaged from the upstream open-source project. Bug reports about module behaviour (not packaging) should go upstream.

https://github.com/tokers/zstd-nginx-module ↗

Related modules

← All modules