Since gzip takes time to pack on the server side, and more time to unpack on the client side, how large does a file need to be in order to benefit from it?
Are there any real numbers out there that demonstrate the efficacy of gzip at common download speeds?
Gzip, the most popular compression method, is used by web servers and browsers to seamlessly compress and decompress content as it's transmitted over the Internet. Used mostly on code and text files, gzip can reduce the size of JavaScript, CSS, and HTML files by up to 90%.
If you take a file that is 1300 bytes and compress it to 800 bytes, it's still transmitted in that same 1500 byte packet regardless, so you've gained nothing. That being the case, you should restrict the gzip compression to files with a size greater than a single packet, 1400 bytes (1.4KB) is a safe value.
GZIP has a size limitation of 4GB, got it from http://www.gzip.org/#faq10 There are some patches mentioned in the above link to be able to read a file more than 4gb.
Enabling gzip compression can reduce the size of the transferred response by up to 90%, which can significantly reduce the amount of time to download the resource, reduce data usage for the client, and improve the time to first render of your pages. See text compression with GZIP to learn more.
It will depend heavily in the nature of the data to be transferred (i.e. how much compressible is the data you are working on). If you are concerned about the time it takes to get the original file on the client side you should compare:
a) time taken to compress the file in the server + time taken to transfer the compressed file from the server to the client + time taken to decompress the file in the client
b) time taken to transfer the original (uncompressed) file from the server to the client.
I believe you would have to try and measure these figures using actual sample data of your application. For example, if you were dealing with video files (uncompressable) then it would probably be better just to send the file without compressing it. However, if for example, you were dealing with text files (highly compressable) then the overall time used for a) might be lower than b)
Not very large, gzip compress text very well, even small. CPU is much cheaper than transfer. 1M file compressed to 100K will be downloaded ten times faster. You should not gzip jpgs,mp3 and any other already compressed data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With