http – What is Gzip? How does it improve a website?


How exactly does Gzip improve a website's performance?

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

I've seen that some sites that test the speed of other sites tend to check gGzip, but what is it?

How exactly does it work?

Why use it?


Gzip is a data compression format. Comes from GNU Zip.

When it is enabled (can turn on and off for each type of content) on the server it is possible to transmit web content faster as it has a smaller volume of data. Of course, the client who will receive the data has to allow this too, otherwise he won't know how to unzip.

In general it should only be used for texts, as other content tends to have naturally compressed formats.

There are certainly gains in static content as the compression can be done beforehand once.

In dynamic content it probably doesn't pay off, because the time gain gained by compression is lost by the time it takes to compress. Each time it generates new content on the server, it has to compress it before sending it to the client.

Only a test with real situations can determine if it will be more useful than in the way, but it almost always doesn't work well.

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

It uses two algorithms, the LZ77 and the Huffman . Depending on the data type, one may be more appropriate than the other. In texts such as 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 this type of file through the HTTP server, the gain is minimal or non-existent since they are compressed. There may be gain because you may be applying a different algorithm.

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

Scroll to Top