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
.ARC , etc.