Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the lower threshold to not perform http compression?

When performing http compression is there low threshold where it is recommended to not perform compression?

Obviously for 100 bytes you would not compress and for 1MB you would. But are there any general recommendation on a specific low threshold?

like image 661
Simon Avatar asked Oct 21 '11 01:10

Simon


People also ask

What is HTTP level compression?

Compression is an important way to increase the performance of a Web site. For some documents, size reduction of up to 70% lowers the bandwidth capacity needs. Over the years, algorithms also got more efficient, and new ones are supported by clients and servers.

Can HTTP requests be compressed?

HTTP compression allows content to be compressed on the server before transmission to the client. For resources such as text this can significantly reduce the size of the response message, leading to reduced bandwidth requirements and download times.

Is HTTP compression good?

One of the fastest and easiest ways one can improve web site/app performance is to reduce the amount of data sent to the client by using HTTP compression. This not only reduces the data used by the user, but can also significantly cut down on the server costs.


3 Answers

IBM has a comparison, which also includes a graph. According to it there is also a benefit for compressing small files. Another, although old article describes gzip's performance as good, except for local file transfers. Although both articles are checking compressions in "dial-up" environment,

I think the question is more relevant as to what to compress, instead of how many bytes. Gzip (deflate) is usually good for textual files (html, xml, js, etc.) even if they are as small as 256 bytes, but is next to useless when compressing media files, or files that have already been compressed (like png, jar-s, docx/odt-s, etc.)

like image 85
SztupY Avatar answered Sep 20 '22 03:09

SztupY


If you really care about it, you should compare the size differences between gzipped and uncompressed real files in your application. Start testing the smallest files you serve, and test increasing sizes. See where the gzipped size is smaller than the uncompressed, and set that to the threshold.

Unless you are Google,1 however, it simply doesn't make much of a difference. Pick a sane value. How does 256 kilobytes sound?


1Okay, okay... O(Google)

like image 45
Matt Ball Avatar answered Sep 19 '22 03:09

Matt Ball


There's not much harm in compressing short HTTP responses. They're not going to get much bigger, if at all. I'd reckon the CPU effort is always worth it if it does save bandwidth.

The better worry is the type of data. Trying to compress tight binary file types like modern image and video formats is a total waste of effort, whereas for all text content it's effective.

like image 26
Boann Avatar answered Sep 21 '22 03:09

Boann