UPDATE: I was wrong about being wrong! In the comments section below, Billy Hoffman has pointed out that gzip compression is still incredibly useful, and that I should do better research. ;)
Today I had to rethink how I serve data to my users.
According to an answer posted on StackOverflow, gzip or deflate compression should be avoided when serving text-based files.
While compressing data to decrease bandwidth and download times generally seems like a great idea, there are a number of problems which have surfaced during the evolution of on-the-fly compression over the wire. After reading the article Lose the wait, I thought more of why I had implemented used mod_gzip in the past and started to realize that the benefits aren’t particularly worth the effort or expense.
- Internet Explorer has a history of issues with receiving compressed payloads — so much history that all gzip/deflate HOWTOs have a line disabling compression for IE, based upon user agent evaluation.
- Uses extra CPU cycles to compress data on each request.
- Requires another module to be loaded into memory (mod_gzip, mod_deflate, etc)
- SSL (HTTPS) connections cannot be compressed.
A better approach is to combine technologies like browser caching and local storage mechanisms, server-side expires tags, and code “minification” to mitigate the need for on-the-fly compression by addressing the underlying issue: management of client-to-server requests.
All that said, compressed http payloads still have a place on the web. For example, Reddit, Digg, Slashdot, or any high-traffic, predominantly text-based site with a large volume of traffic from modern, non-IE web browsers.