Pulkit Gaur

dream - do - deserve

Faster Web page rendering

Filed under: PHP at 07:32:35 On 2006-05-04

HTML files for larger sites can become pretty large themselves.

Gzipping or compressing these files has shown to provide a reduction in the neighboorhood of 70-80% of the original file size, a fairly significant 'weight loss'. I did the same thing for my site's index.php and to my surprise the page size came down to 11 KB flat from a huge 90 KB generated HTML.

The Trick

What you need to do is put is ob_start ("ob_gzhandler"); on the top of each page !

 

 How

We use PHP's ob_gzhandler to send compressed data. This function will first check to see if the browser requesting the file will accept 'gzip,deflate' encoding; if not it sends the file uncompressed. Almost all the browsers support GZip compression. One thing to keep in mind is that , Images are not compressed with this method as only HTML code is rendered via server.

Leave a Comment

Required

Required, hidden