Speed Guide
Enabling Gzip and Brotli Compression on Your Server
Compress HTML, CSS, and JavaScript before they leave your server so every visitor downloads a fraction of the original file size.
Free
SSL so compressed transfers stay secure
NVMe
SSD storage for fast file serving
24/7
Support for server config help
1-click
Installers for CMS platforms
In short
Gzip compression is enabled by adding rules to .htaccess that activate the mod_deflate (or mod_gzip) Apache module, which compresses text-based files like HTML, CSS, JavaScript, and JSON before sending them, often shrinking transfer size by 60-80%. Brotli is a newer, more efficient alternative achieving even smaller output, enabled the same way through .htaccess where the server supports the mod_brotli module, and both can be confirmed by checking the Content-Encoding response header.
Text files compress extremely well because HTML, CSS, and JavaScript are full of repeated patterns, indentation, tag names, common words, that compression algorithms are specifically good at collapsing down. A CSS file that's 100KB uncompressed might transfer at 20-25KB once Gzip runs on it, meaning the visitor's browser receives the exact same content using a fraction of the bandwidth and time.
This is different from image compression, which permanently changes the file. Gzip and Brotli are lossless: the server compresses the file on the fly for transfer, and the browser decompresses it back to the identical original content the instant it arrives, so there's no quality tradeoff to weigh, only a speed gain to capture.
Gzip vs Brotli, what's the difference
Gzip has been the standard for text compression on the web for decades and is universally supported by every browser and server. Brotli, developed more recently, generally achieves 15-20% smaller output than Gzip at similar compression settings for the same file, making it the better choice where it's available, though it requires more CPU to compress at its highest settings.
In practice, a well-configured server should offer both: Brotli for browsers that support it (which is effectively all current ones) and Gzip as a fallback for anything older, letting the server negotiate automatically based on what the visitor's browser reports it accepts.
Enabling Gzip through .htaccess
The standard approach wraps rules in an IfModule mod_deflate.c block and uses AddOutputFilterByType DEFLATE followed by the MIME types you want compressed, typically text/html, text/css, application/javascript, application/json, and text/xml. Some configurations also exclude already-compressed file types like images and PDFs from the filter, since compressing an already-compressed format wastes CPU for no gain.
If mod_deflate isn't enabled at the server level, the .htaccess rule won't have any effect even though it's syntactically correct, since the module itself has to be active on the server for the directive to do anything. This is one of the more common reasons Gzip rules appear to 'not work' after being added correctly.
Enabling Brotli where it's supported
Brotli is enabled through a similar .htaccess pattern using an IfModule mod_brotli.c or mod_filter.c block with directives like AddOutputFilterByType BROTLI_COMPRESS for the same set of text MIME types. Not every hosting environment has the Brotli module compiled in, since it's newer than Gzip and less universally available, so checking with your host or trying the rule and confirming the header is the fastest way to know if it's active.
Where Brotli isn't available, Gzip alone still delivers most of the compression benefit, so it's worth enabling as a baseline regardless of whether Brotli support gets added later.
Verifying compression is active
The most reliable check is your browser's DevTools Network tab: click any HTML, CSS, or JS request and look for a Content-Encoding header in the response, reading either gzip or br (Brotli's header value). If that header is missing, the file is being served uncompressed regardless of what your .htaccess file says.
Third-party tools built specifically for this, along with general speed testing tools like PageSpeed Insights, will also flag any text resources served without compression as part of a broader audit. If Gzip appears active for HTML but not CSS or JS, double-check that all the relevant MIME types were included in the AddOutputFilterByType line, since a narrow rule only compresses what it explicitly lists.

Compression Plus Fast Storage, Together
Compression reduces how much data has to travel over the network, but the server still has to read the file from disk and compress it on the fly for every uncached request, so storage and processing speed still matter for how quickly that compressed response gets assembled and sent.
Hosting Cheap runs every account on pure NVMe SSD storage with LiteSpeed, and full .htaccess access means you can enable Gzip and Brotli rules directly without waiting on a support ticket, while 24/7 human support is available if a rule isn't taking effect as expected.
- Full .htaccess access to enable Gzip and Brotli directly
- NVMe SSD storage for fast file reads before compression
- LiteSpeed server with efficient built-in compression handling
- 24/7 human support to troubleshoot compression headers
Why Hosting Cheap
What you get
Smaller transfer sizes
Text files can shrink 60-80% in transferred size with no quality tradeoff.
Faster page rendering
Smaller CSS and JS payloads mean the browser starts rendering sooner.
Bandwidth savings
Compressed responses use less data for every single page request.
Better speed audit scores
Resolves the common 'enable text compression' warning in PageSpeed tools.
No visual tradeoff
Gzip and Brotli are lossless, the decompressed content is byte-for-byte identical.
Works across your whole site
Once enabled in .htaccess, compression applies automatically to matching file types.
How It Works
Get set up in a few steps
Add compression rules to .htaccess
Wrap AddOutputFilterByType directives in IfModule blocks for Gzip and Brotli.
List the correct MIME types
Include HTML, CSS, JavaScript, JSON, and XML for the widest compression coverage.
Verify via response headers
Check Content-Encoding in DevTools to confirm gzip or br is actually being applied.
Included
Everything you need, on every plan
- Wrap Gzip rules in an IfModule mod_deflate.c block
- Add Brotli rules in a separate IfModule mod_brotli.c block if supported
- Cover all major text MIME types: HTML, CSS, JS, JSON, XML
- Exclude already-compressed formats like images and PDFs from the filter
- Confirm the module is active on the server, not just the rule present
- Check Content-Encoding headers in DevTools after making changes
- Re-run a speed audit to confirm the warning is resolved
FAQ
Frequently asked questions
How to enable Gzip compression if .htaccess changes don't work?
Confirm the mod_deflate module is actually enabled at the server level, since the .htaccess directive has no effect if the underlying Apache module isn't active, and your host's support team can confirm this.
Is Brotli better than Gzip?
Yes, Brotli typically compresses text files 15-20% smaller than Gzip at comparable settings, though it's slightly newer and not universally available on every server.
Does Gzip compression reduce image file size?
No, Gzip is for text-based files like HTML, CSS, and JavaScript, images need separate compression through resizing and format conversion instead.
How do I check if compression is working?
Open browser DevTools, click any HTML/CSS/JS request under the Network tab, and look for a Content-Encoding header reading gzip or br in the response.
Will enabling compression slow down my server?
Compression adds a small amount of CPU overhead per request, but it's negligible on modern hardware and vastly outweighed by the bandwidth and transfer time saved.
Do I need both Gzip and Brotli enabled?
Enabling both is ideal, the server automatically serves Brotli to browsers that support it and falls back to Gzip for anything that doesn't.
Compress and Speed Up on the Right Hosting
Get full .htaccess access on NVMe SSD hosting to enable Gzip and Brotli, backed by 24/7 support.
Get Started