25: How to use GZIP and PHP for speed.

GZIP is a software application used for file compression/decompression. GZIP is short for GNU zip; as the program was created as a free software replacement for the compress program used in early Unix systems, intended for use by the GNU Project. Version 0.1 was first publicly released on October 31, 1992. Version 1.0 followed in February 1993.

GZIP replaces patent-encumbered data compression algorithms.
Many client libraries, browsers, and server platforms (including Apache and Microsoft IIS) support GZIP. GZIP is often used in web applications and software such as PHP to improve speed. Hypertext PreProcessor (PHP) is a server-side HTML embedded scripting language. PHP is not always provided by a hosting server or may be a “paid” option.

Finding out how to use PHP-GZIP is a goose-chase even though the solution is really simple. PHP is something that need to be “switched on” on the server. Check your ISP for how to do this. Or assume it’s on and test.

To convert an HTML file to PHP. Change the .html or .htm extension to .php. This will break your links so you’ll probably have to rebuild them or use a search and replace tool in a text editor.

Add the following line of code BEFORE the opening HTML tag at the top of your code.

<? ob_start("ob_gzhandler"); ?>

* This source code was highlighted with Source Code Highlighter.

That’s it. Simple. You can test to see if PHP is activated with YSLOW or PageSpeed tools. GZIP-PHP can compress the HTML code by 50% to 70%. It does not compress images.

Study: Web Users Prefer Speed Over Customization
The most important interface design factor is speed, according to a new HCI study. Good interface design is essential for widespread user adoption and ultimately website success.

Return to Top ▲Return to Top ▲