Gzip compression enabled

2 May 2012

As part of the constant improvements being made here at The Dark Fortress, a site-wide compression function has been enabled.

Using one of the modules included in the Apache server we use, a compression module has been activated that effectively compresses the file size of all the text, css, xml, htm and javascript pages on this site. The result is a faster load time for these items as well and a decrease in bandwidth useage. Files types already compressed (jpg, gif and png) remain as they are.

The 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 60-70%.

Because Google now ranks pages on their load times in addition to all the previous criteria, smaller file sizes are once again on the agenda — even in the high speed broadband world we now operate in — for maximising SEO performance. It also helps with page loading onto mobile devices where connection speeds may be restricted.

Behind the scenes bits

This module is activated through the site's .htaccess file. Reductions in file size is impressive with page savings of around 60-65% depending on the size of the original page. For those who are interested, the code used is shown below:


<?IfModule mod_deflate.c?>
# compress text, htm, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/htm
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
#
# 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
#
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
<?/IfModule?>

Any problems or page loading glitches that result from this, please report via the Contact us page, or via a personal message to Twitter @thedarkfortress.

Feel free to use this code in your own htaccess file, but please note we cannot accept any responsibility if it doesn't work or causes other problems for you. It works for us – but might not for your site.


If you liked what you saw here, please share it!


blog comments powered by Disqus