All you want to know about Gzip Compression

November 28th, 2018
21 Nov 2018
Chandru Rajendran
No Comments

 

Do you want to see your website loading lightning fast? Then enable gzip compression immediately.

I can hear you whispering how do I do it and why should I. Well, it’s quite natural being skeptical.

Hop in and get some insights.

 

What’s all about gzip compression?

 

 

A known fact: Any process or method used to minimize the size of an object is called compression.

In this case, the sizes of the files are reduced.

Whenever a visitor hits your website, a request is being sent to the server to deliver the requested files for rendering.

It’s too obvious that the larger the size of the file, the longer will be the time taken for viewing it.

Now, think this as a normal user.

Why would you stay on a website that takes time just to display the required?

If you are considering using many tools/practices to reduce the load time of your website, then gzip compression must be at the top of your list.

Thus, it’s a wisely action that you compress all the files now.

 

About the files: Anything specific? 

Almost all the files could be compressed.

Files may be Plain text, HTML, JavaScript, CSS, XML, etc.

Gzip compresses these files and then sends it to the browser.

Now that the files are compressed, it will be light as air and helps in quick transfer time which results in an instant load of your website to the user. This just happened because; the files are way too smaller.

Further to this, you should double check on Render Blocking CSS, JS, as it blocks the load of HTML and impedes Server Response Time.

The big reason 

Ever noticed HTML, CSS files having huge spaces (White to be specific) and loads of repeated text?

Yeah, gzip finds those common strings and compresses it. Want to know how much reduction happens because of gzipping?

Almost 70% + reduction.

 

Web Speed

Join our newsletter to get free tips

 

Is gzip essential?

Absolutely YES.

Before gzip, the server will be having the uncompressed files by default and when the browser sends a request, it sends only the uncompressed version of the files, which is really huge.

I mean, what is the point of all these?

Whereas just imagine; the server is already having compressed files. This time, the browser will be receiving only the compressed version.

So, enabling gzip on the web server would be the perfect way to do it in the right way.

 

See Google’s recommended practice 

Quote from Google – Ilya Grigorik

Compression is the process of encoding information using fewer bits.

 

 

See Gtmetrix results

 

 

Let’s get to know how to enable gzip.

 

How to enable it?

There are multiple ways to enable gzip and of course, there’s no proved reason not to do it.

Most often it is done via web server configuration, yet various servers might have various instructions.

The common ways to enable gzip compression in .htaccess, Apache and Windows (IIS) are being discussed here.

Let’s not wait to know it.

 

How to enable gzip in WordPress via .htaccess?

 

 

We all know that .htaccess file has control over many vital things on your site.

There might be many ways to do it, but I am going to discuss only two in this blog.

One way is using the cache plugin

 

 

You could use a cache plugin, most importantly that which supports enabling gzip compression.

If the requirement is met, you could go ahead and enable HTTP gzip compression.

Cache plugins like W3 Total cache or Gzip ninja speed compression (specific compression plugin) could be used.

In the case of WP Rocket, it adds gzip in the .htaccess file using mod_deflate module by default.

Another prominent way would be by editing the .htaccess file

Just search for the File Manager in the cPanel.

Clicking it will display a popup. All you gotta do is to click the show hidden files.

Now, in that public_html folder, just search for the .htaccess file and edit it.

 

 

Add the below code into the .htaccess file. Make sure that you add these codes below the already existing contents.

Finally, just hit the save button and boom! It is done.

Test if your website is gzipped or not.

 

Web Speed

Check if your website is Gzip enabled right away!

 

You could verify the same by doing a simple test using any other test tools

 

How to enable gzip for apache?

 

 

There are two options for doing this.

Mod_deflate and Mod_gzip

Mod_deflate is a standard recommended module and pretty easy to set up.

Mod_gzip was used in the older versions of Apache and it powerful where you could pre-compress the required contents.

In the end, it really doesn’t matter which options you choose, as both these options provide you with more or less similar compressed files. Generally, it is advisable to use mod_deflate.

Normally, you could find that mod_deflate is enabled by default. Yet, you need to ensure whether it is there already.

For doing this, you need to verify that the following is found in the Apache configuration file.

The next step would be adding the extensions you would like to compress.

To do this, you need to do the changes by editing the Apache configuration.

Now, all you need to do is to add the following line of codes to your .htaccess file

Just save the changes and boom!

Test if your website is gzipped or not.

 

Web Speed

Check if your website is Gzip enabled right away!

 

You could verify the same by doing a simple test using any other test tools

 

How to enable gzip for Nginx?

 

 

It’s pretty simple to enable gzip on Nginx.

If your website runs on Nginx web server, all you need to do is to simply add the following line of codes to your Nginx configuration file.

And that would be nginx.conf

Now, simply add the following and hit the save button

Test if your website is gzipped or not.

 

Web Speed

Check if your website is Gzip enabled right away!

 

You could verify the same by doing a simple test using any other test tools

 

How to enable gzip for windows (IIS)?

 

 

If you are using a Windows IIS server, you could easily enable compression for both the static and the dynamic files.

All you gotta do is to set the entire thing in the IIS manager.

By going to the IIS Manager, you could enable compression for the required websites.

Now, click on the Compression option found under IIS and simply enable Static compression and boom.

Your work to enable gzip here is done.

Hold on! There is something you would want to refer regarding the Microsoft’s guide which I would encourage.

 

It’s show time: Verify whether gzip is enabled on your domain

Hooray! Now that all your craving for enabling gzip compression is done, there is something you should do seriously.

That would be a quick verification on certain tools which would help you to check; how these suggestions are working out for your domain.

 

 

I have given some tools to check if the gzip compression is perfectly working.

https://checkgzipcompression.com/

https://developers.google.com/speed/pagespeed/insights/

https://gtmetrix.com/

http://www.whatsmyip.org/http-compression-test/

 

Have you enabled gzip compression?

Nowadays, all the modern browsers easily understand and then accepts the compressed files.

Since gzip compression nearly saves about 70% of the file size, the file request time reduces drastically and your webpage loads insanely fast.

Hence, if you are planning to load your website faster than it is now, simply go ahead and enable gzip compression immediately, if not done already.

Thereby you are letting your users enjoy the benefits, which reflects in your business hike.

Hope this article is really useful to you.

Make your website to load super fast. Congrats on that. 🙂

 

I am glad to know how you would enable gzip compression.

 

Web Speed

Join our newsletter to get free tips

 

Chandru Rajendran

Chandru Rajendran (Chadd) is a professional blogger. He loves to explore newer technologies and analyzes everything from User point and shares his knowledge for the easy understanding. A nature-loving fanatic keeps on gaining technical experience, in addition to being an analyst. He is the product manager of SpeedBoost Cloud Software.
Follow Chandru Rajendran on

Leave a Reply

Your email address will not be published. Required fields are marked *