What is Gzip? How does it improve a website?


How exactly does Gzip improve the performance of a website?

I wanted to know what it's like under the covers.

I've seen that some sites that test the speed of other sites usually check gGzip, but what's this?

How exactly does it work?

Why use it?

asked by anonymous 07.02.2017 / 13:40

3 answers


Gzip is a data compression format. It comes from GNU Zip.

When it is enabled (can on and off for each content type) on the server it is possible to stream web content faster by having a smaller volume of data. Of course the client that will receive the data has to allow this too, otherwise it will not know how to unpack.

In general it should only be used for texts, since other content usually has naturally compressed formats.

Certainly there are gains in static content as compaction can be done once before.

Dynamic content probably does not pay, because the time gain gained by compression is lost by the time it takes to compress. Each time you generate new content on the server you have to compress it before sending it to the client.

Only a test with real situations can determine if it will be more useful than hindering, but almost always does not work.

Compression is done with algorithms that look for repetition patterns and frequency of use, as well as redundancies, all of which can be used to represent a data form smaller than the original. These algorithms are big consumers of processing, it involves a lot of math.

It uses two algorithms, the LZ77 and the Huffman . Depending on the data type one may be more appropriate than another. In texts like HTML, CSS and JS it is possible to obtain reductions greater than 90%.

Images and sounds often use the same or very similar algorithms in their files. If you try to compress through the HTTP server this type of file the gain is minimal or nonexistent since they are compressed. There may be gain because you may be applying a different algorithm.

The process is the same as for files .zip , .rar , .7zip , .ARC , etc.

07.02.2017 / 13:53

Gzip is used to compress the files that your website sends to the browser and thus speed up the transmission of these files.

Depending on the information from the link below, you can gain up to 70% transfer time by enabling file compression.


Each platform has its way of enabling functionality. In IIS just go to your website and the option "Compression" and enable the functionality as picture below:

07.02.2017 / 13:52

In the same way that you "zip" files to reduce size and send by email, Web servers can be configured to do the same with the files that it sends to the client. In the end, the goal is to make more rational use of network resources (data transmission and reception). Gzip is one of the existing formats for file compression.

Obviously, the gain will be very low when doing this for a JPG, PDF, among others. This is because these files already have their compressed format.

However, when it comes to HTML, CSS and Javascript, the gain can be huge, since they are essentially text files whose compression ratio is very high.

However, it should be noted that for content (HTML example) that are generated dynamically, the gain may not be as large as compaction and decompression must be done for each request. In other words, in a context of dynamic content, it may be that you spend more time compressing and decompressing than actually broadcasting.

On the other hand, for static content the benefit of compression can be perceived more easily, since the contents will be zipped only once. The unpacking can also be minimized if the content is cached on the client side.

Virtually every WEB server and clients (such as browsers) have this functionality. A study should be done on a case-by-case basis, checking whether or not it is worth activating this functionality.

07.02.2017 / 14:12