GZIP / Brotli Compression? (Reduce file sizes by 70%)
GZIP / Brotli Compression? (Reduce file sizes by 70%)
Published on July 1, 2025 Last Updated on July 4, 2025
Written by
Morgan Frank - Specialist in Page Speed
We’ve already touched on compression in the context of minification and image optimization. Now, let’s focus on a powerful server-side technique: Gzip and Brotli compression. These are methods for compressing text-based files (HTML, CSS, JavaScript, XML, JSON, etc.) before they are sent from your server to the user’s browser. This significantly reduces file sizes, leading to faster download times and improved page speed.
Think of it like this: Imagine you need to send a long letter. Instead of sending the full letter, you could use a shorthand code to represent common words and phrases. The recipient would then use a “decoder” to convert the shorthand back into the full letter. Gzip and Brotli do something similar with your website’s files.
Before we dive into the specifics, let’s review the key takeaways:
Key Takeaways
Compression Reduces File Size: Gzip and Brotli significantly reduce the size of text-based files (HTML, CSS, JavaScript, etc.) without losing any information (lossless compression).
Faster Downloads: Smaller files download much faster, improving page speed, especially on slower connections.
Server-Side Implementation: Compression is enabled and configured on your web server (Apache, Nginx, etc.) or through your hosting provider or CDN.
Browser Support is Widespread: Virtually all modern browsers support Gzip. Brotli support is also very widespread.
Brotli is Generally Better: Brotli typically achieves higher compression ratios (smaller file sizes) than Gzip.
No Code Changes (Usually): You usually don’t need to modify your website’s code to enable compression. It’s a server-side configuration.
Dynamic and Static Content: Can compress both.
Why Server-Side Compression is Essential
Significant File Size Reduction: Gzip can often reduce file sizes by 70-90%. Brotli can often achieve even higher compression ratios, sometimes 20-30% better than Gzip.
Faster Download Times: Smaller files download much faster, especially for users on slower connections (like mobile networks).
Improved Page Speed: Faster downloads directly translate to faster page load times, improving user experience and SEO.
Reduced Bandwidth Usage: Smaller files use less bandwidth, which can save you money on hosting costs (especially if you’re on a metered plan).
Better User Experience:
Gzip vs. Brotli: Understanding the Difference
Both Gzip and Brotli are lossless compression algorithms, meaning they compress data without losing any information. The original file can be perfectly reconstructed from the compressed version.
Gzip (GNU zip): The older and more widely supported compression algorithm. It’s been around for many years and is supported by virtually all web browsers and servers. Gzip uses the DEFLATE algorithm.
Brotli: A newer compression algorithm developed by Google. It generally provides better compression than Gzip, resulting in even smaller file sizes. Brotli uses a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling.
Key Differences:
Feature
12453_3e8617-a4>
Gzip
12453_15959c-87>
Brotli
12453_2438b4-a3>
Compression
12453_3dfbf4-90>
Good
12453_c85d6c-b6>
Better (often 20-30% smaller files)
12453_c10276-82>
Speed
12453_a7bfce-95>
Faster compression/decompression
12453_9046a9-2b>
Slower compression, fast decompression
12453_cfb55c-a9>
Browser Support
12453_8dced7-cc>
Universal
12453_8f9826-4a>
Very widespread (but not universal)
12453_b52ee9-f5>
Server Support
12453_2571b1-f9>
Universal
12453_c40793-65>
Growing rapidly
12453_ccbee8-cb>
Recommendation:
Prioritize Brotli: If your server and your target audience’s browsers support Brotli, use it. It provides the best compression.
Use Gzip as a Fallback: Configure your server to use Gzip as a fallback for browsers that don’t support Brotli. This ensures that all users benefit from compression.
Enabling Gzip and Brotli Compression
Enabling compression is typically done through your web server’s configuration. You don’t usually need to modify your website’s code itself. The server compresses the files on the fly before sending them to the browser. The browser then decompresses the files automatically.
Apache
On Apache, you use the mod_deflate module for Gzip and the mod_brotli module for Brotli.
Brotli (mod_brotli): You’ll likely need to install the mod_brotli module first (it’s not always included by default). The installation process varies depending on your operating system and Apache version. Consult the mod_brotli documentation for instructions.
http {
brotli on;
brotli_types text/plain text/css application/javascript application/json text/xml application/x javascript image/svg+xml;
brotli_static on;
# Serve pre-compressed .br files if available
brotli_min_length 1000; # Don't compress very small files
brotli_comp_level 6; #Compression Level
}
Brotli_static This is the important settings.
Other Web Servers
If you’re using a different web server (LiteSpeed, IIS, etc.), consult the server’s documentation for instructions on enabling Gzip and Brotli compression.
Checking if Compression is Enabled
You can use several online tools to check if Gzip or Brotli compression is enabled on your website;
Browser DevTools (Network Tab): You can also check the Content-Encoding response header in your browser’s developer tools (Network tab) to see if compression is being used.
Conclusion
Enabling Gzip and Brotli compression is one of the easiest and most impactful website performance optimizations you can make. It’s a server-side configuration change that can significantly reduce file sizes, improve download times, and enhance the user experience, all without requiring changes to your website’s code. Prioritize Brotli if it’s supported, and use Gzip as a fallback. This is a fundamental optimization that every website should implement.
Determined to change that, he built RapidLoad — a smart, AI-driven tool that empowers site owners to dramatically improve speed scores, enhance user experience, and meet Google’s Core Web Vitals without needing to touch a single line of code.