Knowledge and Concepts of Digital Marketing & Management
Gzip-Compression speed your site

What is Gzip Compression and How to Enable It to Make Your Website Faster

Today Google and other search engines have accepted that web page speed is one of the ranking factors for your site. It is because search engines always strive to give better user experience to their users. There are lots of other factors for speeding up your webpage rendering on the browser. Gzip compression is one of them now you want to know more about Gzip compression

Here are the benefits of Gzip compression

  1. It reduces the sizes of pages by up to 70% to 80%
  2. Increase the page speed 
  3. Cost-benefit ratio: high

What is Gzip Compression

Gzip compression is a method of file compression, and it compresses the file size to small, and this small file size takes less time to transfer from server to your browser. Gzip is a type of file format which is a compressed format of the actual size or can say it is the reduced size of the File. This compressed size allows the webserver to serve smaller file sizes which load faster when users load your website on their browser.

If you are doing SEO of your website, than Gzip compression is a common practice, this is very easy, and this small step can give you an edge on your competitors’ website and faster load time of your website will be ranked higher by Google in its SERPs.

Now the question arises how to enable Gzip compression or implement it on our web server.

How to enable Gzip compression

Most of the time people ask how to enable Gzip compression to make site faster. Gzip compression can be enabled via web server configuration, and different web servers have different ways of enablement of Gzip compression. The most common ways of Gzip enablement are through htaccess, Apache, Nginx, and Lightspeed web servers.

Gzip Compression via htaccess File

This is the most common way of enabling gzip compression, in this method you have to copy and paste a code mentioned here into you .htaccess File which is available in your root folder of your hosting Cpanel. If you don’t have access to your server admin panel, then you can ask your hosting provider or your development team to implement the given code in this File. This .htaccess is a kind of communication between you and your server, and you control your server by adding things in this File.

Here is the code which you can copy and paste the same in your htaccess File.

<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.*
</ifModule>
Save this code as it is and refresh your page. Moreover, check your site in gtmatirx tool again.

If you have Apache server and above code doesn’t fulfil your objective, then you should go and copy below code in your htaccess file

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  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

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

If you have NGINX Server type than you need to past following code to your config file

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 the compression on Litespeed web servers

To enable gzip compression on litespeed web server you have to go through the configuration under “tuning”. Just go down to “enable compression” section and check if it is on or if it is not that click edit then turn it on

Pawan Kumar

Add comment

0%
Drag View Close play

Follow us

Follow us here and find the latest updates here