How to Enable Gzip Compression via all Methods

Enable gzip compression
Enable gzip compression

I really don’t know how much you all are aware of Gzip compression, but I say it’s very crucial to know about how to enable gzip compression. So first let’s enter into a clear explanation of gzip compression.

We know that compression refers to:

Reduction of the file size. We make use of compression regularly to compress the file, photo, etc. So you have got a hint right.

About gzip in depth:

Gzip compression:

Gzip is a software application which is either in the form of small application or a small file. Usually, we use compression to compress our bigger files into smaller files.

Here gzip, is used to compress the web page, style sheets, etc. This reduces page size up to 60%-70% making page load much faster so this increases the page speed as well provides your viewer for loading the page fastly.

I guess you are clear exactly what is a gzip?

But want to know how it is possible, that just by compressing web page how will a web page load faster??

Then have a look here.

How gzip works??

If a visitor or someone wants to visit your site, then he will normally type your domain name in the browser. Now, on the other hand, your browser will request web server to provide the website you have typed and in return server will provide the site.

This is the common process which happens.

But if you enable gzip compression to your website, then the file will be compressed up to 60-70% and thereafter it will be provided to the browser.

Since the webpage size is reduced, it will load faster, and if we don’t provide gzip then, The web server will give a larger file; hence, the browser will load our web page slowly.

So, this leads to lowering of our rank in search engines which is really not a good sign because no one likes to spare time for a site which is late to load so make sure to use gzip to avoid this kind of situations.

Just think if your competitor using gzip and you’re not using??

Then definitely, your competitor page will be ranked high when compared to you, no matter how good is your products or content.


So, we should be good at both producing as well at publicising it because,



But how is it possible for gzip to decrease the file size?


Gzip eliminates all the unnecessary resources and repeated codes. It excludes even the repeated text, thereafter it minimises the remaining resources and provides it to the browser.

One should know:

Gzip performs best on text-based assets like CSS, JSS, and HTML. All modern browsers support gzip, so this is how it works, giving us the most benefits.

Now let’s know the benefits of gzip compression

Benefits of using gzip:

Benefits of Gzip Compression



User-experience is the most needed in almost every system. Gzip provides a better loading speed which really satisfies a user because no one wants to stay for more seconds.

Better compression:

Gzip has a higher compression rate and is one of the best compressors; it compresses the page faster and easily.

Search bot:

As explained earlier, based on the page speed ranking is done.

This is because search bots like Googlebot, Bing bot, and other bots get attracted to the size of your file because it is low( if it was gzip compressed). Based on search bot indexing, ranking is provided. Hence, search engines love this kind of website.

Reduce server response:

It reduces server load time because it will no longer wait to process a big amount of request.

Bandwidth usage:

Gzip also saves bandwidth by compressing files.  So we can save bandwidth also.


These are few benefits we can get by enabling Gzip compression to your site.

Until now we are clear about its uses. But implementation is important, right?


We can implement it by enabling it:


How to enable gzip compression??

There are various ways to enable a gzip compression, The most common ways to enable gzip compression including .htacess, Apache, Nginx, and Lightspeed web server.


Enable Compression via .htaccess :

Compression via .htacess is just by adding some code to “.htacess” file and places it on the web server.

Although some plugins are included in gzip activation but they are not effective enough. So adding it manually is the best practice.


Let’s start:

Before starting, I suggest you to keep a backup file of your .htaccess file. It will be really helpful if you get messed up with something.

.htacess is a file like a robots.txt having its own importance on the web server. So, you should be careful.

We should follow like this:

Log into Webserver-> then go to file manager-> .htacess




And your wait for the code is here:

<IfModule mod_deflate.c>

# Compress HTML, CSS, JavaScript, Text, XML and fonts

AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml


Enable compression on Apache web server:

Code provided for .htaccess can also be used for Apache web server. Give a try with the above code, if it works then it well and good or else try the below code

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


Enable compression on Nginx server:

Usually, Nginx server is inbuilt with compression, if the inbuilt feature doesn’t work then copy paste the below code:

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;

gzip_types text/plain text/html text/css application/x-javascript text/xml 
application/xml application/xml+rss text/javascript;

# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";

# Add a vary header for downstream proxies to avoid sending cached gzipped files 
to IE6

gzip_vary on;


Enable compression on LiteSpeed web server:

The best way to do compression in LiteSpeed web server is to its configuration under tuning. You must go bottom to enable compression. And rest it will work itself.

If still it doesn’t work, then, just click edit-> then turn on.

And by this process, it will automatically find the best config for you, Now enabling is all set. But, how to check whether it is perfectly set or not?

To make easier for you, here is the verification.


How to verify compression is working or not?

Finally to verify your Gzip compression you must run a test. There are various sites which offer these types of test.

Those sites are: Gtmetrix.comvarvycheck gzip compression, etc.

This is all about “How to Enable gzip compression” in all methods. I hope it was clear enough. If you have doubts, then don’t hesitate and get it clarified through the contact us page or comment below.

Hope you liked it.


Was this article helpful?

Thanks! Your feedback helps us improve our website


Please enter your comment!
Please enter your name here