Skip to main content

Compression — content compression

This section uses a single On/Off switch in the top corner to turn compression on or off for the domain.

Compression compresses responses right at the edge (gzip / brotli / zstd) before sending them to the client, to reduce bandwidth for text content (HTML, CSS, JS, JSON…). VNIS compresses only when the client accepts it through the Accept-Encoding header. Per-domain configuration overrides the global configuration.

Use this when: your website has a lot of text content and you want faster loading and less bandwidth usage. Example: an API returns large JSON — enable br compression to make responses significantly smaller.

Before you start​

  • The domain has been added and points to VNIS.
  • Compression applies only to the content types in the filter (by default, the global list of text/JSON types… is inherited).

How to configure​

The Compression section uses an On/Off switch in the top corner of the section: switch On = create and apply the compression configuration for the domain (saved immediately, no separate Save needed); switch Off = delete the entire compression configuration of the domain (see Order of evaluation). The fields below are shown even while it is off — you can set them first and then switch On.

  1. Go to Domains → select the domain → Compression tab. Go to Domains → select the domain → Compression tab
  2. Select the Algorithms you want to use (gzip / br / zstd) — the order in the list is the server-side preference order. You must select at least 1 algorithm before the On switch can be turned on (if none is selected → a red banner appears and the switch is greyed out).
  3. Set the Min Size (bytes) — the minimum size for compression.
  4. (Optional) Enter a Content-Type Filter (a comma-separated list). Leave it empty = inherit the global list.
  5. Turn on the On switch in the top corner of the section — the configuration is created with exactly the values shown and compression is enabled immediately. The badge changes to On.
  6. To make changes later (change algorithms, min size, filter): edit the fields directly, then click Save — this button only appears while the switch is On and there are unsaved changes.

Configuration fields​

FieldMeaningValuesDefaultNotes
On/Off switch (top corner of the section)Turns compression on/off for the domain. This is what decides whether a configuration exists: On = creates the record, Off = deletes the recordSwitchOff (not configured)You must select at least 1 algorithm to switch On; Off deletes the entire compression configuration — to turn it back on, you have to configure it again
Min SizeMinimum body size for compressionBytes, ≤ 104,857,600 (100MB)256 (the form shows 1024)Chunked responses (no Content-Length) on the upstream path are compressed regardless of the minimum
AlgorithmsList of algorithms in server preference orderSubset of {gzip, br, zstd}["gzip","br"]When compression is on, at least 1 is required (leaving it empty while on → error 400); the client must accept it via Accept-Encoding
Content-Type FilterContent types that are compressedList (supports the wildcard text/*)Empty = inherit globalIf the final filter (after inheritance) is still empty → nothing is compressed

deflate is supported by the edge, but only through the API. The interface does not show deflate; setting algorithms:["deflate"] through the API compresses with deflate when the client sends Accept-Encoding: deflate. When the client accepts both gzip and deflate, the edge prefers gzip.

Configuration examples​

Example 1 — Compress API JSON with brotli.

  • Switch: On · Algorithms: ["br","gzip"] · Content-Type Filter: application/json · Min Size: 1024.
  • Expected result: JSON responses of at least 1KB are compressed with br (if the client accepts it), with Content-Encoding: br and Vary: Accept-Encoding.
  • How to check: curl -s -H "Accept-Encoding: br" -D - https://domain/api/data -o /dev/null → you see content-encoding: br, vary: accept-encoding is present, and content-length is gone.

Example 2 — Prefer zstd, then br, then gzip for all text on the site.

  • Algorithms: ["zstd","br","gzip"] · Content-Type Filter: text/*, application/javascript, application/json.
  • Result: for a client that sends Accept-Encoding: gzip, br, zstd, the edge chooses zstd (first in the list).
  • How to check: curl -H "Accept-Encoding: gzip, br, zstd" -D - https://domain/ -o /dev/null → content-encoding: zstd.

Example 3 — Compress only HTML/CSS/JS and skip other content types.

  • Switch: On · Algorithms: ["gzip","br"] · Content-Type Filter: text/html, text/css, application/javascript (without application/json).
  • Result: resources whose content type is outside the filter (e.g. JSON) are not compressed.
  • How to check: curl -H "Accept-Encoding: gzip" -D - https://domain/api/data.json -o /dev/null → no content-encoding; whereas curl -H "Accept-Encoding: gzip" -D - https://domain/style.css -o /dev/null → has content-encoding: gzip.

VNIS does not compress content that is already compressed (image/* except image/svg+xml, video/*, audio/*, application/zip|gzip|zstd|br), and does not compress WebSocket/gRPC or responses that are being transformed (image transform, rewrite…).

Order of evaluation​

  • The switch = whether the configuration exists. Switching On = creates the compression configuration record for the domain. Switching Off = deletes that record → the domain goes back to compressing according to the global configuration; to turn it back on, you have to enter the algorithms, min size and filter again from scratch.
  • Domain configuration overrides global. In practice, inheritance applies to the Content-Type Filter when you leave it empty (domain → host → global). For Algorithms, once compression is on you must select at least 1, so it cannot be left empty through a valid Save.
  • The algorithm is chosen by server-side preference: the edge takes the first algorithm in the list that the client accepts. q=0 in Accept-Encoding = the client refuses that algorithm.
  • When compressing, the edge adds Content-Encoding, removes content-length and appends Vary: Accept-Encoding.

Troubleshooting​

SymptomCauseFix
The On switch cannot be turned on (greyed out) + red bannerNo algorithm selectedSelect at least 1 of gzip/br/zstd and switch again (calling the API directly with it empty still returns 400 "at least one algorithm…")
All configuration is gone after switching OffOff = delete the configuration (by design)Turn it back on and re-enter the algorithms/min size/filter
Save returns 400 "must be one of…"The algorithm is not in {gzip,br,zstd,deflate} (for example snappy)Use only gzip/br/zstd in the interface; deflate can only be set through the API
Save returns 400 about min sizemin_size_bytes > 100MBSet it to ≤ 104,857,600
deflate is set but no compression happensThe client does not send Accept-Encoding: deflate, or the client accepts gzip so the edge chooses gzipCheck the client's Accept-Encoding header
No content is compressedThe Content-Type Filter is empty at every level, or the content type does not matchAdd content types (e.g. text/*); leave it empty to inherit global
Compression does not apply to images/videoThat content is already compressedExpected — VNIS intentionally skips it

FAQ​

  • Which algorithm should I use? br (brotli) compresses static text well; zstd is fast and efficient; gzip has the widest compatibility. List them in the order of preference you want.
  • Does leaving the Content-Type Filter empty mean everything is compressed? No — empty means inherit the global list. If the global level is also empty, nothing is compressed.
  • Why are small chunked responses compressed even though they are below Min Size? When Content-Length is missing (chunked/streaming) on the upstream path, the edge compresses regardless of min size.
  • What if the client does not accept compressed content? If the client does not send a matching Accept-Encoding (or sets q=0), the edge returns the uncompressed version.
  • Do I lose my configuration when I switch Off? Yes — Off = delete the domain's entire compression configuration (the domain goes back to the global compression settings). To use it again, you have to configure it from scratch. If you only want to disable it temporarily, consider leaving the switch On and narrowing the Content-Type Filter.