What is Gzip? How does it improve a website?

Asked

Viewed 1,253 times

7

How exactly Gzip improves a site’s performance?

I wonder what it’s like under the table.

I saw that some sites that test the speed of other sites usually check the gGzip, but what is this?

How exactly it works?

Why use it?

3 answers

10


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

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

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

There are certainly gains in static content since compression can be done previously once.

In dynamic content it probably does not compensate, because the time gain obtained by compacting is lost by the time spent to compress. Each time you generate new content on the server you have to compress before sending it to the client.

Only a test with real situations can determine if it will be more useful than hindrance, but almost always does not give good result.

Compression is done with algorithms that search for repetition patterns and usage frequency, as well as redundancies, all of which can be used to represent a given less than the original. These algorithms are large processing consumers, involves a lot of math.

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

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

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

5

gzip is used to compress the files that your website sends to the browser and thus gain speed in the transmission of these files.

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

https://helabs.com/artigos/2013/02/01/melhorando-a-performance-do-web-site-com-gzip/

Each platform has its own way of enabling functionality. On IIS just go to your website and the "Compression" option and enable the functionality as shown below: inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

4

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

Obviously, the gain will be very low when doing this for a JPG, PDF, among others. This occurs as 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 rate is very high.

However, it should be noted that for contents (HTML example) that are generated dynamically, the gain may not be so great, since compression and decompression will have to be done for each request. In other words, in a context of dynamic content, it may be that more time will be spent compressing and unpacking than actually transmitting.

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.