Content Compression Setup (Gzip/Brotli)

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Setting up Gzip/Brotli compression

Transport-level compression reduces HTML, CSS, JS size 3-10 times. Brotli gives 15-25% better compression than Gzip at same CPU. Setup takes 30 minutes and requires no code changes.

Nginx: Gzip + Brotli

# /etc/nginx/nginx.conf or /etc/nginx/conf.d/compression.conf

# Gzip—supported everywhere
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;        # 1-9, CPU/compression balance; 6 is sweet spot
gzip_min_length 256;      # don't compress very small files
gzip_types
    application/javascript
    application/json
    application/xml
    application/rss+xml
    image/svg+xml
    text/css
    text/html
    text/javascript
    text/plain
    text/xml
    font/woff
    font/woff2;

# Brotli—requires ngx_brotli module
# Install: apt install libnginx-mod-brotli
brotli on;
brotli_comp_level 6;
brotli_types
    application/javascript
    application/json
    text/css
    text/html
    text/plain
    image/svg+xml
    font/woff2;

Check:

curl -H "Accept-Encoding: br" -I https://example.ru/
# Response should contain: Content-Encoding: br

curl -H "Accept-Encoding: gzip" -I https://example.ru/
# Response: Content-Encoding: gzip

Pre-compressed static assets

For static files (JS, CSS, bundles)—generate .gz and .br files at build, serve directly. No CPU cost per request:

// vite.config.ts
import { defineConfig } from 'vite';
import viteCompression from 'vite-plugin-compression';

export default defineConfig({
    plugins: [
        viteCompression({ algorithm: 'gzip',   ext: '.gz' }),
        viteCompression({ algorithm: 'brotliCompress', ext: '.br' }),
    ]
});
# Nginx: serve pre-compressed files
location ~* \.(js|css|woff2)$ {
    gzip_static  on;    # look for .gz version
    brotli_static on;   # look for .br version (ngx_brotli module)
    expires 1y;
    add_header Cache-Control "public, immutable";
}

Apache

# .htaccess
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript
    AddOutputFilterByType DEFLATE application/json image/svg+xml font/woff2
</IfModule>

Laravel: middleware for API

// Laravel doesn't compress responses by default
// Add middleware in bootstrap/app.php for API
->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        \Illuminate\Http\Middleware\GzipResponse::class, // Laravel 11+
    ]);
})

Or via Nginx—preferred for performance.

Typical compression results

File Original Gzip Brotli
app.js 500 KB 150 KB 130 KB
app.css 80 KB 18 KB 15 KB
HTML page 50 KB 12 KB 10 KB

Setup time: 30 minutes for Nginx configuration.