What advantages do either method offer for html, css and javascript files served by a LAMP server. Are there better alternatives?
The server provides information to a map application using Json, so a high volume of small files.
See also Is there any performance hit involved in choosing gzip over deflate for http compression?
Best Answer
The simple answer is don't.
RFC 2616 defines deflate as:
The zlib format is defined in RFC 1950 as :
So, a few headers and an ADLER32 checksum
RFC 2616 defines gzip as:
RFC 1952 defines the compressed data as:
CRC-32 is slower than ADLER32
So ... we have 2 compression mechanisms that use the same algorithm for compression, but a different algorithm for headers and checksum.
Now, the underlying TCP packets are already pretty reliable, so the issue here is not Adler 32 vs CRC-32 that GZIP uses.
Turns out many browsers over the years implemented an incorrect deflate algorithm. Instead of expecting the zlib header in RFC 1950 they simply expected the compressed payload. Similarly various web servers made the same mistake.
So, over the years browsers started implementing a fuzzy logic deflate implementation, they try for zlib header and adler checksum, if that fails they try for payload.
The result of having complex logic like that is that it is often broken. Verve Studio have a user contributed test section that show how bad the situation is.
For example: deflate works in Safari 4.0 but is broken in Safari 5.1, it also always has issues on IE.
So, best thing to do is avoid deflate altogether, the minor speed boost (due to adler 32) is not worth the risk of broken payloads.