Elliott C. Back: Technology FTW!

Http Gzip Compression in PHP

Posted in Blogging, Computers & Technology, How to Blog, Performance, SEO, Spread IE, Web 2.0 by Elliott Back on January 12th, 2006.

GZIP compression saves as much as 70% of the size on a text-heavy webpage. What does this mean for your users? Faster loading websites and less latency. What does this mean for your server? Less load and less bandwidth will be used if you judiciously compress and cache.

In PHP, there are two easy ways to do this. The first is to add the following to your .htaccess file and let Apache do the rest:

php_flag zlib.output_compression on
php_value zlib.output_compression_level 2

The second is to add the following to the top of your php script file:

ob_start(”ob_gzhandler”);

Either way, you can check the results of your page online.

This entry was posted on Thursday, January 12th, 2006 at 10:54 pm and is tagged with output compression, compression level, gzip compression, script file, php script, htaccess, bandwidth, apache. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

Viewing 7 Comments

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus