Monday, December 12, 2011

GZIP compression for better performance

Compression is easy and effective way to reduce the bandwidth to download data from internet and increase the performance of the web site. In other words, server sends the compressed HTML in the form of zip file to the client and the client browser unzips the file to retrieve the HTML. All the latest browsers support gzip/deflate. 


Why we need it?


Lets understand how the web model works. When we visit the web page e.g. http://jassra.com/, basically we are requesting for Index file from the server and server returns the same file to the client.


The way communication takes place between the client and the server is described below:
  1. Browser requests a file from the server and the data sent for the request is 100 B
  2. Server finds the requested file
  3. Creates HTML for the response
  4. Server sends 1.9 KB of data back to the browser. And user needs to wait for the data to be downloaded and finally browser displays the page
Network trace


Now with gzip if we can compress the file to reduce the size of the file and less data needs to be transferred to the client resulting in less bandwidth and quick response.
  1. Browser requests a file from server. Data sent for the request is 100 B
  2. Server finds the requested file
  3. Creates HTML for the response and  zips the file
  4. Server sends 874 B of data back to the browser. 874 B of data is downloaded quickly as compared to the uncompressed data and browser displays the page much faster
Means Happy Customer..... :o)

Network trace



For more understanding about how gzip algorithm works, please view this video.



Please feel free to leave your feedback ....

No comments:

Post a Comment