KLB
07-17-2006, 09:12 PM
After spending the weekend tweaking and optimizing my site, I started to run out of ways to make it faster, but I read about gziping html/php files on the fly which will significantly reduce their download size and signficantly speed up the download of webpage especially on dialup connections. While there are several different server addins that can do this, if one is running PHP on Apache as a module there may not be any additions needed. All one needs to do is add the following to their .htaccess file:
php_value output_handler ob_gzhandler
This assumes that the webpages are being parsed by PHP so if the webpages are static HTML file one might need to add the following before the instruction above:
AddType application/x-httpd-php .html
It will work for any file extension that is set to be parsed by PHP. Trying to gzip CSS files might cause havoc on older browsers. This will signficantly speed up the download of sites for almost all browsers and the gzip files are only sent to browsers that can support them. I found it works great for MSIE6, Firefox and Opera. In fact based on some tests I ran, I think my users on 56K connections will see the load time of my pages go from around 20 seconds to around 11 seconds. Obviously your mileage will vary. More documentation on this can be found at:
http://us2.php.net/ob_gzhandler
You can test your site to see how this is working at: http://leknor.com/code/gziped.php
Another really useful tool for analyze and optimize one's site is at:
http://www.websiteoptimization.com/services/analyze/
We all know how important it is to make our pages load as quickly as possible and this is a really cheap trick.
php_value output_handler ob_gzhandler
This assumes that the webpages are being parsed by PHP so if the webpages are static HTML file one might need to add the following before the instruction above:
AddType application/x-httpd-php .html
It will work for any file extension that is set to be parsed by PHP. Trying to gzip CSS files might cause havoc on older browsers. This will signficantly speed up the download of sites for almost all browsers and the gzip files are only sent to browsers that can support them. I found it works great for MSIE6, Firefox and Opera. In fact based on some tests I ran, I think my users on 56K connections will see the load time of my pages go from around 20 seconds to around 11 seconds. Obviously your mileage will vary. More documentation on this can be found at:
http://us2.php.net/ob_gzhandler
You can test your site to see how this is working at: http://leknor.com/code/gziped.php
Another really useful tool for analyze and optimize one's site is at:
http://www.websiteoptimization.com/services/analyze/
We all know how important it is to make our pages load as quickly as possible and this is a really cheap trick.