While perusing through the countless design/development blogs out there I came across Pointless Existence, and a very easy to implement method for reducing bandwidth usage for sites with Apache/PHP servers.
Basically, the following code is placed at the top of your PHP pages:
<?php ob_start("ob_gzhandler"); ?>
When the page is requested, the server will remove whitespace and compress the document to the tune of 25-75% depending on the density of the code. Inspired by this post, I did some Googling and found “The Definitive Post on Gzipping your CSS” at Fifty Four Eleven from June 13th. How did I not know about this before? In the spirit of the ongoing inside joke in our office – “Hello, and Welcome to LAST WEEK!”
6 comments on “Gzipping, Duh!”
I checked this site before gzipping my home page, and apparently gzipping reduced the file to 34% of its original size – that’s down 66%! Awesome!
That is all fine and dandy with just one problem: mondo CPU overhead. It definatley will decrease bandwidth usage but at the penalty of more processing time for the server to respond to requests, and more processing on the client to unzip the request.
If the connection is slow it will probably result in a speedup since you are reducing the cost at the bottleneck, on a fast connection this could slow down the apparent response time. Anyone have a graph response time vs bandwidth?
Ahh, I guess that is what partly what the Leknor site you linked to does. To bad that when I tried to read it before commenting it was really slow to respond….
Yea, I hear ya Nathan, but I don’t see anyone out there giving Gzip bad reviews. If the bandwidth to processing time trade-off sucked then noone would use it. Not that my webhost has any processor cycles to spare on compressing my pages, but you have to admit that a 66% decrease in transfered data is pretty decent.
Hi, I’m the author of the original post on my blog. I’d just like to point out, that there is a slight increase in cpu usage, but nothing negligible. The significant bandwidth offset justifies this many times over. Many large sites use it, and many large PHP scripts use it, especially the forums. I’m sure if it caused a high burden on the CPU then, they wouldn’t choose to use it.
Thank you for your input Edward! …and a “So THERE!” to you Birdman! 🙂