Gzip Compression

Gzip Compression

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%.

In 2009, 90% of internet traffic travelled through browsers that supported. Gzip. Today:

All modern browsers support and automatically negotiate GZIP compression for all HTTP requests: our job is to ensure that the server is properly configured to serve the compressed resource when requested by the client.

On an Apache-based server, you can do that through the `.htaccess` file:

# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

That’s essentially a list of MIME types that gzipping will then apply to. Feel free alter the list to all text based assets you serve.

The HTML5 Boilerplate project offers server configs for all the popular servers. This is it’s version for .htaccess

Would you like to share your thoughts?

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