For more detailed description go to http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

You can simply set up the site compression by editing the .htaccess file on the server.

For example,

# compress all text & html:
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/css

AddType text/html .shtml .php .php3 .js .js.gz
AddType text/css .css
AddOutputFilter INCLUDES .shtml .php .php3 .js .js.gz .css

If you don’t have access to the .htaccess file, you can try this in your php file.

Advertisements