How to enable gzip compression in Tengine
2026-09-29
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;
gzip_types— list the text formats; files not listed stay uncompressedgzip_min_length 1024— skip tiny responses where compression costs more than it savesgzip_comp_level 6— good balance; 9 barely helps and burns CPUgzip_vary on— sendsVary: Accept-Encodingso caches store the right variant
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.