Published in CSS on Monday, May 10th, 2004
Results of collecting snapshots of http compression data within a two month period.
Note: The "official line" on this topic is being archived and updated here.
A while back I wrote up a post that explained how you could use PHP's output buffering to take advantage of HTTP Compression and compress your CSS files. To summarize, your css files download faster by compressing them with PHP's built in compression handling (smaller filesize = shorter download, simple!).
I thought I would pass along some of the data we collected from several client sites during the months of March and April.
Note: if you aren't familiar with HTTP Compression, check out this rather long but informative article: HTTP Compression Speeds up the Web.
The data was collected in random snapshots - windows of time where we collect user data for our clients websites. Basically, if the user-agent is not some type of bot we initiate a session and set a cookie. We have some flaming-hoops (conditions) that a user must pass before real data is collected, in an effort to try and collect reliable data.
Without going into too much detail, lets just say that the data was very reliable (you'll have to take my word on this one, we've worked hard to filter out rotten data).
Similar to Apache's mod_gzip and mod_deflate functions, PHP's ob_gzhandler checks to see what type of content encoding the users browser will accept and sends the appropriate data.
For example, if your browser sends an 'accept encoding' header of 'gzip, deflate' it will receive the compressed CSS file. Otherwise it will receive an uncompressed version of the file.
Content Encoding is part of the HTTP 1.1 standard, and most modern browsers will accept compressed data (for more details see the article linked in the third paragraph). So why do we collect numbers?
Some firewall programs, and likely other devices and software, have been known to block your browser from sending the 'accept-encoding' information. When this happens, the uncompressed version of the file is delivered.
Okay, the results:
# of sessions | # that accepted compression | % that accepted compression |
---|---|---|
117956 | 94238 | 78.82 |
On average the css files were compressed to 21% of their original size.
Not much to say here, other than that it works and we're going to continue using it. We'll keep evaluating the data, to help us estimate a number for 'bandwidth savings for the overall site'.
Sitepoint's web devlopment books have helped me out on many occasions both for finding a quick solution to a problem but also to level out my knowlegde in weaker areas (JavaScript, I'm looking at you!). I am recommending the following titles from my bookshelf:
I started freelancing by diving in head first and getting on with it. Many years and a lot of experience later I was still able to take away some gems from this book, and there are plenty I wish I had thought of beforehand. If you are new to freelancing and have a lot of questions (or maybe don't know what questions to ask!) do yourself a favor and at least check out the sample chapters.
The author line-up for this book says it all. 7 excellent developers show you how to get your JavaScript coding up to speed with 7 chapters of great theory, code and examples. Metaprogramming with JavaScript (chapter 5 from Dan Webb) really helped me iron out some things I was missing about JavaScript. That said each chapter really helped me to develop my JavaScript skills beyond simple Ajax calls and html insertion with libs like JQuery.
Like the other books listed here, this provides a great reference for the PHP developer looking to have the right answers from the right people at their fingertips. I tend to pull this off the shelf when I need to delve into new territory and usually find a workable solution to keep development moving. This only needs to happen once and you recoup the price of the book in time saved from having to develop the solution or find the right pattern for getting the job done..
Comments and Feedback
Nice follow-up on the original article. Thanks.