Green Clook

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:

Gzip Compression

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:

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

Enabling compression on Apache webservers

If gzip fails using the instructions above, remove the code added to .htaccess and replace with:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Checking Gzip is enabled on Apache

A good tool to analyse on site performance is 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:

Gzip Compression

About The Author

Scott is a UX Designer and Developer at Clook. He’s passionate about UI Design, WordPress Development and Marketing.

Working on the creative, branding and marketing side of Clook. He's involved in creating a variety of digital and print designs for us.

Connect on Linkedin

Clook Logo

Get regular tips, tricks and updates!

Signup today for our awesome newsletter and recieve monthly emails with all sorts of helpful articles on hosting and web development.