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.
Some content types such as zip files or gif images are already compressed and do not respond well to compression. In fact, attempting to compress them can increase the size of the response message and waste CPU time on the server.
Compression is particularly useful where secure SSL connections are used, because it reduces the amount of content that has to be encrypted on the server and decrypted by the client.
Two compression algorithms are commonly used - deflate and gzip. HTTP clients indicate their support of compression using the Accept-Encoding header as shown here:
A server will only compress content for clients that support compression and will set the Content-Encoding header so that the client knows which algorithm to use when reading the response body:
If you look at the response message for a compressed page you will see that the response headers are in clear, uncompressed text and the HTML content is in a compressed binary format:
Question: How much difference did compression* make to each of the following?
Using HttpWatch with Example 8
To view the effect of HTTP compression on this page: