What is GZIP vs Brotli compression?
Answer
Both are server-side text compression algorithms that reduce the size of HTML, CSS, JavaScript, JSON, and other text responses. GZIP: the traditional standard, supported everywhere. Typically reduces response size by 60-80%. Configure in Nginx: gzip on; gzip_types text/css application/javascript. Brotli: Google's modern compression algorithm. Achieves 15-20% better compression ratios than GZIP with similar compression speed. Supported in all modern browsers (IE doesn't support it). Use Brotli for modern browsers and GZIP as fallback. Browser signals support via Accept-Encoding: br, gzip header. Nginx Brotli: install ngx_brotli module. Static vs dynamic compression: statically pre-compress assets at build time for maximum compression levels. Dynamically compress responses for frequently-changing content. Impact: a 200KB JavaScript file compressed to 60KB with Brotli saves significant bandwidth, especially on mobile. Compression is one of the easiest wins — enable it on all text responses in production. Binary formats (images, video) are already compressed and should not be GZIP/Brotli compressed.
Previous
What is HTTP/2 and HTTP/3 and how do they improve performance?
Next
How do you optimize React applications for performance?