Total Pageviews

How to enable gzip compression on website pages

Speed testing urls:
http://developer.yahoo.com/performance/rules.html#gzip
https://developers.google.com/speed/pagespeed/insights



Check speed report at: http://gtmetrix.com/reports

          

I added this in my .htaccess, and it works:

# compress the files
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
# removes some bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

It compresses quite a lot, so I think that i's worth using it!
========
I too tried an htacces method and failed. However I had success inserrting the following PHP line at the top of each page.

<? ob_start("ob_gzhandler"); ?>

If, like me, your code is HTML then you need the following in your htacces file

RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

...........this enables PHP expressions within your code.to work

Takes longer to do and probably not for large web sites but one check said my html files were reduced by over 70% in most cases
===============

0 comments:

Post a Comment