Configuring Gzip Compression for 1C-Bitrix
Configuring Gzip Compression for 1C-Bitrix
Gzip is the first thing a PageSpeed auditor checks after installing Bitrix on a new server. Surprisingly often it is not configured at all, or configured incorrectly: HTML is compressed but JS and CSS are not, or the compression level is set to maximum and burns CPU without meaningful benefit. A typical catalog page HTML is 80–200 KB; after Gzip level 6 it is 15–35 KB — a 75–80% traffic saving on every uncached HTML request.
nginx Configuration
The standard Bitrix installation via setup.sh configures basic Gzip, but it frequently misses important MIME types and does not enable gzip_vary.
Full configuration in the http or server block:
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss
application/rss+xml
application/atom+xml
image/svg+xml
font/ttf
font/otf
application/vnd.ms-fontobject;
gzip_vary on — critical when a CDN or proxy is in use. Adds the Vary: Accept-Encoding header so caches do not serve compressed content to browsers that do not support Gzip.
gzip_min_length 1024 — do not compress files smaller than 1 KB. The Gzip header overhead and CPU cost are not justified for small responses.
gzip_comp_level 6 — levels 7–9 provide less than 2% additional compression while increasing CPU usage by 2–3x. Levels 1–2 are fast but compress 15–20% worse.
Common Configuration Mistakes in Bitrix
Double compression via PHP and nginx. Bitrix can compress responses via PHP (ob_gzhandler). If compression is enabled in both PHP and nginx — the browser receives doubly compressed content and cannot decompress it.
Check in /etc/php/*/fpm/php.ini or bitrix/php_interface/dbconn.php:
; Must be off if nginx handles gzip
zlib.output_compression = Off
And in Bitrix settings: Settings → Product Settings → Page Compression — disable if nginx handles compression.
Missing gzip_proxied any — if the site is behind a load balancer or CDN, nginx without this directive will not compress responses for proxied requests (when a Via header is present).
application/json not in the list. Bitrix API responses (components running in AJAX mode) return JSON. Without compression, JSON responses for a catalog of 50 products weigh 40–80 KB; with compression — 8–15 KB.
Apache Configuration
For Bitrix servers on Apache (bitrix-env uses nginx as a front end, but shared hosting often runs pure Apache):
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css application/javascript
AddOutputFilterByType DEFLATE application/json application/xml
AddOutputFilterByType DEFLATE image/svg+xml font/ttf
DeflateCompressionLevel 6
# Do not compress already compressed formats
SetEnvIfNoCase Request_URI \.(?:gif|jpg|jpeg|png|zip|gz|br)$ no-gzip dont-vary
Header append Vary Accept-Encoding
</IfModule>
Static Pre-gzip for Bitrix Assets
nginx can serve pre-compressed files via the gzip_static on directive:
gzip_static on;
When app.js is requested, nginx looks for app.js.gz. If found — it is served with no CPU compression cost. Generate .gz files in the deploy script:
find /var/www/site/public/build -name "*.js" -o -name "*.css" | \
xargs -P4 -I{} gzip -k -6 {}
Verification
# Verify response compression
curl -sI -H "Accept-Encoding: gzip" https://site.ru/ | grep -i content-encoding
# Content-Encoding: gzip
# Compare sizes
curl -s --compressed https://site.ru/ | wc -c
curl -s -H "Accept-Encoding: identity" https://site.ru/ | wc -c
The Check GZIP compression tool shows compression status for any URL along with byte savings.







