How to Enable Compression
Optimising your website will not only provide a better visitor experience, it will also position you to rank well with Google, Bing, Yahoo and other search engines. One way to speed up websites is to enable gzip compression…
What is compression?
Compression is a way of compressing files sent from your server to increase the speed to which they are transferred to the user’s web browser.
It can reduce page sizes by up to 70% and subsequently improve load times.
Activating compression for Litespeed
If your server is running Litespeed Web Server – which includes all our shared, reseller and optweb servers – then Brotli compression is enabled by default.
Brotli compression is newer and slightly faster than the standard GZip compression, but not all page speed testing services can detect it yet.
You can confirm Brotli compression is active in the site’s headers by looking for “content-encoding: br” like this:
Litespeed will silently fall back to GZip on any browser that isn’t compatible with Brotli.
Activating compression for Apache
Depending on your Content Management System, and/or server type you will find there are various methods to enable Gzip compression…
WordPress and Gzip compression
Most popular caching plugins have the facility to enable the function via their settings. I use WP Fastest Cache and the option is available via the settings home page:
Enable compression via .htaccess
Typically when enabling Gzip via a WordPress plug-in it is done by adding content to your .htaccess file. If you do not use WordPress or prefer not to use a caching add-on, you can enable Gzip compression manually by adding the following to .htaccess:
Enabling compression on Apache webservers
If gzip fails using the instructions above, remove the code added to .htaccess and replace with:
Checking Gzip is enabled on Apache
A good tool to analyse on site performance is GTmetrix.com. A previous blog post Improve Your GTmetrix Score in Under 30 Minutes gives insight on steps you can take to improve your score. Enter your website url, click ‘Analyse’ and once the report has run you will be notified whether Gzip has been enabled successfully: