Brotli or Gzip: Which Offers Better Compression?
Research shows that Brotli frequently surpasses Gzip in compression ratio, particularly for JavaScript, CSS, and HTML files. Brotli can realize up to 21% superior compression for HTML files compared to Gzip.
Can Brotli and Gzip Be Used Together?
Brotli and Gzip are not mutually exclusive. Enabling Origin Shielding is crucial for Brotli's effectiveness, allowing for both to be used in tandem for maximum benefits.
Gzip's Effectiveness on Text-Based Content
Gzip excels in compressing text-centric content, achieving compression ratios as high as 70-90% for larger files. Its performance is lesser on assets that are pre-compressed.
How to Enable Brotli for Text Compression
To activate Brotli, utilize the a2enmod brotli command. Configure your server to append the proper AddOutputFilterByType directive for specifying file types for compression.
Speed Comparison: Is Brotli Faster Than Gzip?
Brotli aims to outpace Gzip in both compression and decompression. Front-end decompression can be up to 64% faster when using Brotli.
Drawbacks of Using Gzip
Employing Gzip can increase CPU and memory usage on the server, potentially impacting its performance and scalability, especially when managing numerous requests or large files.
Choosing the Right Compression Level for Brotli
For precompressed resources, Brotli level 11 is recommended. For real-time compression, level 4 or 5 should suffice in achieving a smaller payload compared to the highest Gzip compression level.
Which Compression is Best for Text?
Lossless methods like Brotli and Gzip maintain the original text quality but might demand more storage space. Your choice between lossless and lossy techniques depends on your specific requirements.