What is the brotli compression algorithm
brotli was originally released in 2015 for offline compression of web fonts. Google software engineers released an enhanced version of brotli in September 2015 that included general lossless data compression, with a special focus on http compression. The encoder has been partially rewritten to improve compression ratio, both the encoder and decoder have been increased in speed, and the streaming API has been improved to add more compression quality levels. The new version also showcases cross-platform performance improvements and reduced memory required for decoding.
Unlike common general-purpose compression algorithms, brotli uses a predefined 120 kilobyte dictionary. The dictionary contains over 13,000 common words, phrases, and other substrings drawn from a large corpus of text and HTML documents. Predefined algorithms increase compression density for smaller files.
Using brotli instead of deflate to compress text files can usually increase the compression density by 20%, while the compression and decompression speeds remain roughly unchanged. The content encoding type for stream compression using brotli has been proposed to use "br".
Installation
git clone https://github.com/google/ngx_brotli cd ngx_brotli && git submodule update --init
http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; keepalive_timeout 65; #brotli compression brotli on; brotli_comp_level 6; brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml; ……
accept-encoding:gzip, deflate, br
Configuration instructions
Instruction introduction
brotli on;
brotli_types text/plain text/css text/xml application/xml application/json text/javascript application/javascript application/x-javascript;
brotli_static off;
brotli_comp_level 11;
brotli_buffers 16 8k;
brotli_window 512k;
brotli_min_length 20;
The above is the detailed content of How to enable Brotli compression algorithm for Nginx. For more information, please follow other related articles on the PHP Chinese website!