How to enable gzip compression in Tengine

2026-09-29

AdSense Slot

Gzip is the baseline compression every web server should have: it typically shrinks HTML and CSS by 60–80% before anything reaches the user. Unlike Brotli, gzip is built into every Tengine by default — it is often just not turned on. Here is the config and the verification step that catches the “I enabled it but nothing changed” cases.

The config

Add to the http block:

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_vary on;

Reload and verify

nginx -t && nginx -s reload
curl -I -H "Accept-Encoding: gzip" https://yourdomain.com/

You want to see content-encoding: gzip and a vary: Accept-Encoding header. If you get neither, the two causes are: the type is not in gzip_types, or the response is smaller than gzip_min_length.

Gzip vs Brotli

If your build has Brotli, prefer it — my Brotli guide covers that. You can run both: send Brotli when the client supports it, gzip otherwise. The one rule is: never compress already-compressed assets (jpg, png, zip) with either — it is wasted CPU for zero gain.

Summary

Gzip is on by default in the module set but off in config; enabling it is four lines. Verify with a curl that sends Accept-Encoding: gzip, and check the file type list before blaming anything else. Pair it with 512MB VPS tuning and your small box serves a lot more traffic comfortably.

AdSense Slot