• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / nginx server tutorials (installation, configuration, performance tuning, security) / enable brotli compression nginx brotli vs gzip

enable brotli compression nginx brotli vs gzip

 

 

Table of Contents

Toggle
  • #1 Install Brotil Module precompiled ubuntu & debian
    • #1.1 Add Repository if not yet added by default
    • #1.3 installing brotle from source github compiling on server
  • #2 Load module in nginx .conf top
  • #3 Replace  Gzip conf with Brotil bottom of nginx.conf
    • #3.1 Use along with Gzip
  • #4 Restart nginx and verify the compression Accept-encoding
  • #1 Installing Brotil in Apache ubuntu debian
  • #2 Configuring brotil in apache
  • GZIP (Deflate) vs Bortil
  • Why we use brotil instead of gzip?
    • Troubleshooting

#1 Install Brotil Module precompiled ubuntu & debian

sudo apt-get install brotli nginx nginx-module-brotli

#1.1 Add Repository if not yet added by default

sudo apt-add-repository -y ppa:hda-me/nginx-stable
sudo apt-get update

check nginx version stable or mainline and current version.

and repeat 1st step,

#1.3 installing brotle from source github compiling on server

check how to add dynamic module in nginx.

pagespeed module nginx

 

#2 Load module in nginx .conf top

nano /etc/nginx/nginx.conf

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

#3 Replace  Gzip conf with Brotil bottom of nginx.conf

#brotli
 brotli              on;
 brotli_comp_level   5;
 brotli_static       on;
 brotli_types        text/xml image/svg+xml application/x-font-ttf image/vnd.microsoft.icon application/x-font-opentype application/json font/eot application/vnd.ms-fontobject application/javascript font/otf application/xml application/xhtml+xml text/javascript  application/x-javascript text/plain application/x-font-truetype application/xml+rss image/x-icon font/opentype text/css image/x-win-bitmap;

compression level 0-11.

you may use html separate compression level

 

#3.1 Use along with Gzip

You can place brotli compression. below the GZIP. browsers automatically choose between them based on supported compression.

 

 

#4 Restart nginx and verify the compression Accept-encoding

 

 

systemctl restart nginx

 

HTTP/2.0 200 OK
server: nginx
content-type: text/html; charset=UTF-8
vary: Accept-Encoding, 
content-encoding: br

Content length with gzip

content length with brotil

  • Compile & install Nginx from source with brotli support
    & Remove existing
    Starts or restarts Nginx

#1 Installing Brotil in Apache ubuntu debian

 

sudo apt install brotli && sudo a2enmod brotli

 

#2 Configuring brotil in apache

 

you can edit conf directory in conf directory or module directory.

 

Adding to host for specific directory website.

    
<IfModule mod_brotli.c>
    AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/json application/x-font-ttf application/vnd.ms-fontobject image/x-icon
    </IfModule>

3. systemctl restart apache2

 

verifying  terminal  or online curl tool or chrome de tools

curl -I -H 'Accept-Encoding: br' https://rajuginni.com


curl -I https://rajuginni.com
curl -I -H 'Accept-Encoding: gzip' https://rajuginni.com

 

 

content-encoding: br

GZIP (Deflate) vs Bortil

 

GZIP: LZ77 +Huffman coding = Deflate algorithm.

General Rule: brotil compress better than gzip.

 

Why we use brotil instead of gzip?

faster than gzip, efficient than gzip.

it uses a dictionary of common keywords and phrases on both client and server side and thus gives a better compression ratio.

Js 14%, html 21%, Css 17% smaller than gzip as per recent study.

Images: may already compressed.

Compression level 1-11 (11 means high compression) 1MB file 1KB means 90% compression.

pagespeed improment maybe upto 30%-50% for static files.

gzip compression level by default 5 you may increase upto 11 for static files.

the downside is compression time. do test and deploy.

improve Page load speed 3 seconds to 2 seconds (30% smaller page size than gzip)

 

 

 

Troubleshooting

The following packages have unmet dependencies:
nginx-module-brotli : Depends: nginx (= 1.17.3-2-ppa7~bionic)   (compiled with 1.17 )
E: Unable to correct problems, you have held broken packages.

root@instance-1:~# nginx -V

nginx version: nginx/1.19.1

built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) (Bionic )

we need to compile with installed nginx. or remove old nginx, install with brotil.  dynamic module.

Brotil by google at github

nginx server tutorials (installation, configuration, performance tuning, security)

  • Letsencrypt SSL Installation on apache/Nginx ubuntu / debian wordpress
  • fix error 520 522 524 on cloudflare wordpress godaddy nginx etc
  • nginx fastcgi cache wordpress how to configure
  • install LEMP Stack on 22.04 LTS Nginx MySQL PHP fpm #wordpress #digital ocean
  • Apache vs nginx (connection handling, modules, memory usage)
  • Pagespeed module install, configure, monitor, errors ft nginx &apache
  • nginx errors (504,502, 413, unable to start, syntax errors)
  • nginx conf explained best config file performance tuning tips nginx.conf location errors tutorial
  • use nginx as reverse proxy and load balancer for apache wordpress
  • nginx rewrite rules with examples 301 redirection
  • nginx modules list (enable, disable, upgrade, install dynamic module)
  • php fpm pool manager configuration settings based on server spike high cpu wordpress
  • php fpm restart nginx ubuntu enable status page, monitor etc
  • what is TTFB & how to Reduce it (server response time) Google pagespeed
  • letsencrypt install configure on ubuntu / debian nginx
  • Top 10 tips to improve nginx server security
  • nginx performance tuning connections, buffers file descriptors
  • enable brotli compression nginx brotli vs gzip
  • nginx installation on ubuntu 20.04 LTS
  • monitor nginx request with nginx status amplify datadog new relic
  • SSL faster reduce TLS hand shake improve https performance
  • nginx rate limiting explained by location time specific url
  • datadog nginx integration installation process
  • newrelic nginx integration process and errors fix and metrics
  • php fpm seems busy fixed warning and max children reached to handle max connections / requests
  • Php fpm configuration for 1000 concurrent connections server busy max children reached
  • php fpm ondemand vs dynamic vs Static (the dynamic pool problem)
  • nginx upstream response is buffered to a temporary file
  • php fpm install ubuntu 20.04 nginx
  • install phpmyadmin ubuntu nginx 22.04
  • upgrade php fpm ubuntu nginx 7.4 to 8.2
  • nginx add last modified header (remove, php wordpress)
  • php fpm dynamic pool manager settings
  • nginx fastcgi cache purge
  • nginx open file limit connections ulimits sysctl
  • php fpm high cpu usage WordPress 4 solutions nay work for you
  • nginx buffer size for wordpress
  • Cloudflare error code 524 nginx a timeout error occured
  • server configuration for 1000 concurrent users

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy