Performance and monitoring
Disable Gzip and Brotli compression from .htaccess
Our servers automatically compress HTML, CSS and JavaScript with Gzip or Brotli. If an application or script does not work properly with the compressed response (for example, because it already compresses the output itself, or because it streams data), you can disable compression from .htaccess. The change takes effect immediately, without restarting anything.
Disable it
Add this at the beginning of the .htaccess file:
SetEnv no-gzip 1 SetEnv no-brotli 1
The first line disables Gzip and the second Brotli. Add both: if you only disable Gzip, modern browsers will keep receiving Brotli.
If you prefer to use rewrite rules, the alternative for Gzip is:
RewriteEngine On RewriteRule . - [E=no-gzip:1]
SetEnv is the option LiteSpeed recommends, because other RewriteRule rules in the file (WordPress's, for example) can stop the rewrite rule from being applied.
Choose where to put it
The .htaccess file affects its own directory and every directory below it:
- In
public_html/.htaccess, compression is disabled for the main domain and for any addon domains and subdomains whose folders are insidepublic_html. - To limit it to a single website or folder (for example, an API's), put it in that folder's
.htaccess.
Check that it has been disabled
- Open the website in a private window, press F12 and go to the Network tab.
- Reload with Ctrl + F5 (or Cmd + Shift + R on a Mac) so you do not see the browser's cached copy.
- Click the request for the document or file you are interested in and look at the response headers:
Content-Encoding: gziporContent-Encoding: brshould no longer appear.
You can also check it from the terminal with:
curl -s -o /dev/null -D - -H "Accept-Encoding: gzip, br" https://tudominio.com/ | grep -i content-encoding
If it returns nothing, the response is uncompressed.
If it still appears compressed, the cause may be:
- A CDN such as Cloudflare: it compresses what it delivers to the visitor itself. Disable it on the CDN or check directly against the server.
- The application itself: if the PHP code uses
ob_gzhandlerorzlib.output_compression, that compression is not controlled by the server. Remove it from the code or setzlib.output_compression = Offin the website's PHP configuration.
Turn it back on
Delete the lines you added and save. Compression works again immediately. Keeping it on greatly reduces the size of your pages, so only disable it where you need to.
You may also find useful
- Web compression with Brotli and Gzip Clarifies which content LiteSpeed compresses automatically and how the server chooses Brotli or Gzip...
- Gzip compression, saving transfer and speeding up access Explains how Gzip and Brotli reduce the size of text content and why LiteSpeed applies them automati...
- AccelerateWP: what it is, how to turn it on in cPanel and what each option does Turn on AccelerateWP for your WordPress from cPanel, understand what each section of the plugin does...
- Adjust the WordPress memory limit Tell apart the memory WordPress requests, PHP's effective limit and the account's memory before rais...
Something wrong or out of date? Tell us and we will review it.