What is GZIP compression

You can reduce size of the Http response (HTML, CSS, JavaScript ) by zipping your response (Approximately 70% reduction in response size). Its same as normal zip that we use for sending files as email attachment, with difference that in this case either your Application Server of Http Server will zip the response and the browser knows how to unzip the response. Reducing size of response will result in faster network response time and as a result improve the web site performance.

Starting from Http 1.1, browser can let your Http Server know that it can handle zipped content by sending Accept-Encoding header in request like this

 
Accept-Encoding: gzip, deflate


This header tells the server that browser know how to unzip content zipped using either gzip or deflate.

When web server sees this, it might decide to zip the response using one of the method that browser understand say gzip, so first it zips the response and sets Content-Encoding header like this on the response to let browser know that the response is zipped and the method used for zipping response


Content-Encoding: gzip


There are two methods for zipping the Http Response one is gzip and other is deflate. Most of the browsers support gzip but not deflate. Some of the browsers that do support deflate, also support gzip, so we should use gzip as much as possible.

1 comment: