-
Website
http://paulbuchheit.blogspot.com/ -
Original page
http://paulbuchheit.blogspot.com/2009/04/make-your-site-faster-and-cheaper-to.html -
Subscribe
All Comments -
Community
-
Top Commenters
-
Mustafa K. Isik
2 comments · 1 points
-
Daniel Ha
5 comments · 405 points
-
Eric Eldon
2 comments · 13 points
-
Danielle Fong
3 comments · 1 points
-
nivi
6 comments · 18 points
-
-
Popular Threads
-
So I finally tried Wave...
3 weeks ago · 46 comments
-
So I finally tried Wave...
They last tested during the days of IE6 and FF1.0, though. I imagine that the clients are much faster now, but this analysis isn't complete without an end-to-end comparison.
> per page to compress the data, even though it will make their
> site much more responsive.
I used to work on drivers for network interfaces, some years ago. Transmitting a packet from the web server isn't free. Depending on the OS it might first need to be copied from the web server into the kernel, then be processed by the kernel's IP stack, split up into 1500 byte chunks for the ethernet interface with TCP/IP headers prepended, and finally enqueued for DMA.
10-15 usec of CPU time to transmit a maximum sized TCP/IP frame to an ethernet interface is not unreasonable.
Your compression test reduced the HTML size by 110636 bytes, which would reduce the number of ethernet frames transmitted by 76 packets. Thats about 0.75 to 1.1 msec of CPU time.
Additionally, those 76 packets would have required 38 acknowledgements from the remote system to be processed. Processing received packets is slightly more expensive because an interrupt is generally required, so I'll assume 15-20 usec. Thats another 1/2 to 3/4 msec of CPU.
Finally, of those 9 msec about half were in user space to run the actual compression code, and half was spent in the filesystem. A web server compressing data in memory wouldn't have so much system overhead. The actual CPU time consumed would be closer to 5 msec.
So where did we end up? We spent 5 msec of CPU time on compression, but we save 1-2 msec in CPU cost elsewhere. Spending the time on something highly compressible like HTML saves CPU time elsewhere in the system.
I'll agree with Ivo that there is significant startup time in compression operations, compressing a bunch of small files takes longer than one big file. Nonetheless its still a pretty good tradeoff.
can i has unlimited happiness?
And for users on plans with severe bandwidth limits (e.g. mobile phones) you save users costs too.
1. Concatenate your JS and CSS files. Don't send out several files over the wire to the browser - the browser can only make 2 connections at a time. Be careful about JS dependencies - order is imp. in JS.
2. Minify and then compress the JS and CSS. Use Dojo's Shrinksafe or the YUI Compressor to do this. It will strip out whitespace, etc - make the code smaller in size (In JS, every byte counts) and compress.
3. Now gzip the above.
Write an Ant script to automate all the above on code commit and you are done. Try other methods like loading other elements in the background or after a tab etc is clicked - important to show something to the user almost instantly. Did this for Alertle.com, which was a 100% AJAX web app (no page refresh at all), and the initial size of the code being sent to the browser went from 700k to about 20k using the steps above :)
4. I prefer to concatenate and "shrink" my CSS and JS on the server, dynamically, with every request. You may think this is a bad idea until you read #5....
5. I concatenate them into two files, with the greatest "last-modified" datestamp of all the concatenated files serving as a suffix on the filename:
concatenated_20090417_235959.js
concatenated_20090417_235959.css
And I set an HTTP "Expires" header of 1 year on these files. This way browsers almost never re-download the JS and CSS (unless it's actually changed).
I find this strikes a nice balance between performance and ease-of-maintenance: any change to the CSS or JS is picked up right away, without any need to run a build.
2. If anyone is running a browser that is lower than IE 6.0, they have bigger issues than worrying about compression. Every browser released since 2001 handles HTTP compression flawlessly (except for the IE 6 JS issue, which is just insane and conditional responses will deal with that).
3. Measure your performance FROM THE CLIENT SIDE with and without compression. Server-side processing time is important, but how long does it take to send the file along the wire to its destination.
You can even compress content in many shared hosting Wordpress environments by placing the '<?php ob_gzhandler(); ?>' command at the very top of the header.php file.
Good luck and happy compressing.
smp
http://newestindustry.org/category/webperforman...
http://site-perf.com/cgi-bin/show.cgi?id=4nUAyu...
does not use the gzip encoding!
You mention nginx, but I wanted to add that anyone is using a reasonably modern build of apache/httpd either as their primary web content server or in a proxy-balancer configuration can also do this very very easily, and handle the historical browser issues that people mentioned:
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/xml application/xhtml+xml text/javasc
ript application/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
PLEASE VISIT MY BLOGS
http://www.onlinespacer.blogspot.com/
and
http://www.worldofjewellery.blogspot.com/
These blogs are for charity donation for poor childern. The money that is earn from this blog which i completely spread into them. Please Please Please I again says that Please visit those blogs and click one google add (ads by google) and send me comments on it and follow my blog as a friend Because that question not for me its for humanity! :(
Log on to eProjecthelp.com today.
www.eprojecthelp.com
And if it is how can I implement it?
Thank you!