Search This Blog

Saturday, September 12, 2009

PHP, Compress Your Web Page to Speed Up

Compress your web page (on the server side) can save a lot of bandwidth.
Using gzip, the compression rate is usually over 50% !
You can test if your web page supports compression.
Just add the following line on the top of your PHP page.
(remember enclosed it with the php tag)

if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();

Saving 5k (bytes) might not make your client feel the significant speedup, but it does cut down a lot of
your server traffic. Saving traffic is saving money.

If you can change your .htaccess, change it there for a server-wide improvement.

No comments: