Main Content

Compressing web pages sent out from server. Is it worth it?

Archive - Originally posted on "The Horse's Mouth" - 2007-09-14 16:57:26 - Graham Ellis

Web servers can compress .html and similar files before they send them out - a great way to keep traffic volume down where bandwidth is more of a consideration than processor power. But what proportion of browsers can accept compressed data? That's a darned good question which I was asked on today's Tomcat Deployment course.

Adding in a few lines on the end of a PHP script that encapsulates all our web pages, I kep a log file for a short while. And out of a sample of 1380 hits on our web site ...
1035 (75%) could accept gzip compression
822 (60%) could accept deflate compression
166 (12%) could accept x-gzip compression
Only 245 requests (18%) did not include any notice that they could receive compressed responses.

Here's the PHP code I used ...

$fho = fopen("$_SERVER[DOCUMENT_ROOT]/../compress.dat","a");
fputs($fho,"$_SERVER[HTTP_ACCEPT_ENCODING]\n");
fclose($fho);


Remember that images are already compressed (part of the format of a.jpg, for example), so there's little point in trying to have the server compress them ... but for a busy, bandwidth limited setup at server and/or browser, I conclude that compression IS worthwhile.