Home Tech Development & Design What is GZIP compression?

What is GZIP compression?

5 min read

GZIP compression is bundling (zipping) pages on a web server before the page is sent to the visitor.
This saves bandwidth and therefore increases the loading speed of the page significantly.
The visitors’ web browser then automatically unzips the pages. This compressing and unzipping only takes a fraction of a second.

GZIP compression is recommended for all types of text files such as:
– HTML (.html) but also all types of dynamic HTML (such as extension .php, .aspx)
– Textfiles (extension .txt)
– CSS and Javascript (extension .css and .js)
– Webservices, such as WSDL, REST and JSON

GZIP compression is not recommended for non-text files, such as graphical files and .zip files because it hardly saves space and can therefore increase the loading time.

Why is GZIP compression important?

GZIP compression saves 50% to 80% bandwidth and will therefore significantly increase the website’s loading speed.
The textfiles are compressed (zipped) on the web server after which the visitor’s web browser will automatically unzip the files. This compressing and unzipping only takes a fraction of a second without the end user noticing.

Where is GZIP compression used?

GZIP compression must be installed on the web server, such as in Apache, IIS and nginx. When retrieving the website the web browser will prompt the visitor he/she can receive the GZIP.

Then the web server will send the files GZIP-compressed to the web browser, after which the web browser will unzip them.

If the visitor’s web browser does not support GZIP, the files will be sent back to the visitor in their original state (uncompressed).

How to enable GZIP compression?

Nowadays it is very easy to set up GZIP compression on new web servers. In Apache, this is usually already a default setting in the module mod_deflate. In IIS, you can set it up in “website properties” (Tab Services), and then allow “compress application files”.

CAUSION: Always make a back-up of the server settings before you make any changes to the web server configuration!

For Apache

You will need to add the following lines to 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





Load More Related Articles
Load More By Kuldeep Singh
Load More In Development & Design

Leave a Reply

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

Check Also

Kalan Recipe, how to Make Kerala Style Kalan Recipe | Kalan Curry Recipe

Kalan recipe with step by step photos – kalan is a gravy based dish from the kerala cuisin…