Gzip Compression for Bitrix: Performance & Bandwidth Savings

Gzip is the first thing a PageSpeed auditor checks after a Bitrix installation. We often see it either completely disabled or incorrectly configured. HTML is compressed, but JS and CSS are not, or the compression level is set to maximum, eating CPU without noticeable benefit. A typical catalog HTML

Our competencies:

Frequently Asked Questions

Gzip is the first thing a PageSpeed auditor checks after a Bitrix installation. We often see it either completely disabled or incorrectly configured. HTML is compressed, but JS and CSS are not, or the compression level is set to maximum, eating CPU without noticeable benefit. A typical catalog HTML page is 80–200 KB; after gzip level 6, it drops to 15–35 KB. That's a 75–80% traffic savings on every non-cached HTML request. For a store with 10,000 daily visitors, this significantly reduces server load and improves LCP. We have helped over 500 projects configure compression — with more than 10 years of experience.

Want to configure gzip correctly? Order an audit and setup — a typical project takes 2–4 hours, cost is calculated individually.

How Gzip Affects Load Speed

Compression reduces the amount of data transferred. For HTML — 4–6 times smaller, for CSS/JS — 3–5 times. For example, a catalog page without compression weighs 180 KB, with compression — 25 KB. On mobile internet, this saves 3–5 seconds of load time. Gzip is supported by all modern browsers, and search engines consider speed as a ranking factor.

Comparison: gzip_static vs Dynamic Compression

Static pre-gzip (gzip_static) is 3 times less CPU-intensive than dynamic compression because files are compressed once at deploy time. Dynamic compression processes every request; at level 6, it offers excellent compression but loads CPU. For static resources (CSS, JS), gzip_static is preferable. Here is a comparison table:

Parameter gzip_static Dynamic gzip
CPU load None (serving pre-made files) 3x at level 6
Delivery speed Maximum Slightly slower
File updates Requires regenerating .gz Automatic
Support nginx only All servers

Compression Efficiency by Content Type

Content Type Size Without Compression Size With Compression (gzip 6) Savings
HTML catalog page 180 KB 25 KB 86%
CSS file (bootstrap) 150 KB 35 KB 77%
JavaScript (jquery) 85 KB 20 KB 76%
JSON API response 50 KB 10 KB 80%

Why gzip_static is Better for High-Load Projects

On projects with millions of static file requests, the CPU load from dynamic compression can be 10–15% of total resources. gzip_static removes it entirely. In one of our projects (a catalog with 1 million products), switching to gzip_static reduced CPU from 60% to 35%, and static response time dropped by 200 ms. Get a consultation if you want to implement gzip_static on your project.

How to Configure Gzip in nginx: Step-by-Step Guide

The standard Bitrix installation via setup.sh sets up basic gzip, but often misses important MIME types and does not enable gzip_vary.

Step 1: Basic Configuration

Complete 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 using a CDN or proxy. Adds the Vary: Accept-Encoding header so that caches don't serve compressed content to browsers without gzip support.

gzip_min_length 1024 — do not compress files smaller than 1 KB. The overhead of gzip headers and CPU is not justified for small responses.

gzip_comp_level 6 — levels 7–9 give less than 2% additional compression at 2–3x CPU cost. Level 1–2 is fast but compresses 15–20% worse. According to tests, level 6 offers the best ratio of compression to performance.

Step 2: Enabling gzip_static

gzip_static on; — when requesting app.js, nginx looks for app.js.gz. If found, it serves it without CPU cost for compression.

Generation of .gz files in deploy script:

find /var/www/site/public/build -name "*.js" -o -name "*.css" | xargs -P4 -I{} gzip -k -6 {} 

Step 3: Check for Double Compression

Bitrix can compress responses via PHP (ob_gzhandler). If both PHP and nginx compression are enabled, the browser receives doubly compressed content. Check php.ini or bitrix/php_interface/dbconn.phpzlib.output_compression should be Off. In Bitrix settings: "Settings → Product Settings → Page Compression" should be disabled if nginx handles compression.

What to Choose: gzip_static or Dynamic Compression on Apache?

On servers with nginx (Bitrix recommendation), configuration is simpler and more efficient — one-time compression, static pre-gzip. Apache requires the mod_deflate module, which uses more CPU. On shared hosting, the choice is usually limited. In any case, gzip should be enabled at the web server level, not through PHP.

Apache Configuration

For Bitrix servers on Apache (bitrix-env uses nginx as frontend, but on shared hosting often 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 # Don't compress already compressed formats SetEnvIfNoCase Request_URI \.(?:gif|jpg|jpeg|png|zip|gz|br)$ no-gzip dont-vary Header append Vary Accept-Encoding </IfModule> 

Common Bitrix Configuration Mistakes

Double compression via PHP and nginx. We already mentioned it — disable zlib.output_compression.

Missing gzip_proxied any — if the site is behind a load balancer or CDN, nginx without this directive does not compress responses for proxied requests (the Via header is present).

application/json not in the list. Bitrix API responses (components working in AJAX mode) return JSON. Without compression, JSON responses for a catalog with 50 items weigh 40–80 KB; with compression, 8–15 KB.

Checking Compression

# Check 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 at GiftOfSpeed shows compression for any URL along with byte savings.

What's Included in Our Gzip Setup Service

  • Audit of current server and Bitrix configuration.
  • Gzip setup on nginx or Apache with verification of all MIME types.
  • Optimization of compression level and caching.
  • Setting up gzip_static for static resources.
  • Checking for double compression, adjusting PHP and Bitrix.
  • Testing via PageSpeed, GTmetrix, and curl.
  • Documentation of changes made.
  • Consultation and support for one week after setup.

We guarantee results: load time improvement in tests by 30-400% (depending on current state). If you're unsure about your configuration, contact us for a free project assessment. Get a consultation on gzip setup for your Bitrix project.