handbook

Tuesday, December 27, 2005

 

Web Page Compression

So, I’ve been fiddling with compressing my pages to reduce bandwidth. I had been using ob_gzhander, which compresses pages at the script level, but the other day I figured out how to get zlib.output_compression working, which compresses pages at the web server level. [ini_set wasn’t working, but I figured out I could enable it via .htaccess.]

I tried the different compression levels and recorded the compressed page size and the page generation time for each level. I used my November 2005 archive page for the test. Here’s the results:

compression level page size
(kB)
av. gen time
(sec)
std. dev.
-1 (default) 108.5 2.20 .06
0 512.6 3.80 .65
1 121.5 2.20 .10
2 118.1 2.20 .12
3 116.3 2.20 .10
4 111.5 2.20 .10
5 109.2 2.20 .16
6 108.5 2.19 .06
7 108.4 2.17 .06
8 108.4 2.30 .14
9 108.4 2.30 .17

So it turns out the default level of compression, which appears to be compression level 6, is a good choice to use. Interestingly, my page generation time increases when I don’t compress the page. Since the compression is done by the web server and not PHP, compression should have no effect on the generation time. This suggests there’s probably something wrong with my page generation timer code and that it’s waiting for some action from the client.

I’m sure no one but me cares. 🙂




Leave a Reply

site-map