Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.
Step 1 :
Check Nginx web server/Proxy is already installed on your server
Step 2 :
Download and install Nginx Static Brotli module:
cd /etc/nginx/modules wget http://dl1.centos-webpanel.com/files/nginx/modules/nginx-brotli-modules.zip unzip nginx-brotli-modules.zip rm -rf nginx-brotli-modules.zip
Step 3 :
Now add nginx module configuration on "nginx.conf":
nano /etc/nginx/nginx.conf
Now add these lines on top of the nginx.conf:
load_module "modules/ngx_http_brotli_filter_module.so"; load_module "modules/ngx_http_brotli_static_module.so";
Now add brotli compression configuration in nginx.conf file in
http {
section and before http closing
}
:
#brotli brotli on; brotli_comp_level 6; 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;
Save the file and restart nginx :
service nginx restart OR systemctl restart nginx
Go to this site for the checks : https://www.giftofspeed.com/gzip-test/</a.
For the advanced user you can check content-encoding via http header:
HTTP/2.0 200 OK server: nginx content-type: text/html; charset=UTF-8 vary: Accept-Encoding, Cookie content-encoding: br