Htaccess: Turn on Gzip compression

Gzip compression is a technology that minimizes the size of browser-based HTTP responses sometimes by as much as 70%.

Using Gzip compression can speed up your site’s load times significantly.

There are two ways to turn on Gzip compression on your site.

You can:

1. Add the following code to your site’s .htaccess file:

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:

<files *.html>
SetOutputFilter DEFLATE
</files>

2. Add the following code to the top of your HTML or PHP page:

<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?>

Thanks so much to hostgator for this data:
http://blog.hostgator.com/2013/03/26/7-ways-to-speed-up-your-website/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>