Just like gzip, Brotli is also a compression algorithm. It is developed by Google and serves best for text compression. The reason being, it uses a dictionary of common keywords and phrases on both client and server side and thus gives a better compression ratio. It is supported by all major browsers
Gzip vs Brotli
The advantage for Brotli over gzip is that it makes use of a dictionary and thus it only needs to send keys instead of full keywords. According to certsimple,
- HTML files are 21% smaller than gzip.
- CSS files are 17% smaller than gzip.
Install brotili as php module
git clone --recursive --depth=1 https://github.com/kjdev/php-ext-brotli.git
Create brotli.ini file in mods-available directory of php conf directory
and add the below line. For php 7.1, /etc/php/7.1/mods-available/brotli.ini
service apache2 restart
Check content-encoding header in the response. If content-encoding : br header is present in the response headers, it’s working fine.