Compression

Zstandard Compression

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

nginx-module-zstd

Install

You'll need nginx from nginx.org configured first. These packages won't load on the distro nginx.

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 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 came from Meta, open-sourced in 2016. Compression ratios similar to brotli, but faster to decompress on the client. Browser support is getting there: Chrome has it, Firefox too, Safari is catching up. For large JSON payloads or binary content where decompression speed matters, zstd is worth trying. We ship it now because that's when you should be testing it, not after browser support hits 95%. Pair it with nginx-module-zstd-static for pre-compressed static assets and zero per-request CPU cost.

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. Adjust to taste.

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

We package this from the upstream open-source project. If it's a bug in the module itself (not in our packaging), report it upstream.

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

Related modules

← All modules