I don’t know, If you all developers are aware to Gzip compression or not. I’m sure most of people don’t know about it that how to enable Gzip compression for sites.

May you have read about Leverage Browser caching in earlier post through .htaccess file. Now We will steps to compression through .htaccess file, which is used to optimize website landing speed.

What is Gzip Compression

It is a software application, which contains a piece of code to reduce file size upto 70% of actual size. Basically it is used to compress bigger files (xml, css, js etc) to small files and compress images as well.

It is about to compress webpage, scripts and style sheets upto 60%, which enables fast landing speed. It reduces webpage loading time by smart compression technique.

I know, you got the point but is it possible to increase speed by using such piece of code ? Let’s move on.

How it works and deliver fast landing

Normally If we hit to an URL, it follows http cycle with request and response objects. After this cycle user sees the webpage on browser. Sometime users get bored if webpage takes more time to render on browser or doesn’t get proper output.

If you enable compression, than a request is also made to this tool and response back to browser. All files are compressed without loosing quality and come back to browser with normal behaviour.

Page loads slowly if we don’t enable to compression and it affects to website ranking. Because Search Engines have some minimum time 200ms to load a webpage and response to browser.

Now you must want to know how to enable compression to your website. So, let know about this.

Enable compression through .htaccess file

.htaccess file has own importance on webserver so you must have a backup of file before you are going to edit. If there is no such file in site directory, you can create it manually.

Here is lines of code to paste there and enable compression to load pages faster than normally.

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/vnd.ms-fontobject

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

</IfModule>

Before couple of years I was not aware of such code, while spent more than 8 months in development field. Once I was checking website speed through Google and found this. After that I found this code on Stackoverlow and results was good.

My site was loading in 27s before using it, and than just 4.58s. It was faster than previous result and glad to get this code.

Enable on Apache Server

You can also use such piece of code, while apache server is there. Please have a look an 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

You can do this manually by hosting server, while some of them provide in-built tool to compress files. I’m using 2gbhosting solutions and there is an option in cPanal to compress files and images before it sent to browser.

Conclusion: I will suggest to use this, while If you are thinking about fast landing speed. I’m using this code since two years and got good results each time. I hope it would be helpful for you in website ranking too.

If you have something to add to this blog? Kindly share it in the comments. Thank you for reading this.

30%* off! Get going with GoDaddy!

LEAVE A REPLY