LyncServe Insight
Your resource for technology, design and marketing insights that impact today's business.

Speed Up Your Website – Enable GZIP Compression

Staging Environment on computer

In the articles I have written regarding the internal workings of websites, the strong, consistent theme is the importance of optimizing the performance of your website. Many factors contribute to ensuring your website is constructed for enhanced performance, such as image optimization, browser caching, and more. Another great tool to use in this process is GZIP compression.

A GZIP compression enabled website allows your web server to provide smaller, compressed versions of the files that make up your website. The end user is then able to access your website faster. Time is a critical element for end users. If they can't retrieve the information they are looking for quickly, they will surely go elsewhere to find it. Therefore, it is not just important to have quality information on your website in a well-organized manner, it is vital to make sure your site is optimized to deliver information as promptly as possible.

Implementing GZIP Compression

GZIP compression is relatively simple to implement for a web developer. In fact, in most server environments, it should be considered a standard part of optimizing your website. There are very few drawbacks to using GZIP compression (which generally apply to the webserver delivering the site, not to the consumer using the website). Using GZIP compression typically costs the webserver a small amount of additional processing power to serve the compressed files to the end user. Most webserver configurations, not already strained for processing power, should experience few repercussions from serving a compressed version of a website. In most cases, the benefits to the user from GZIP compression vastly outweigh the marginal additional processing power on the web server.

Coding GZIP Compression

In an apache environment, it is possible to enable GZIP by placing code into your .htaccess file. When altering an .htaccess file, it is always a good idea to keep a backup of the file before any changes are made. An incorrectly configured .htaccess file can prevent your webserver from delivering the site to the browser at all. Below is a common implementation of GZIP compression via .htacess:

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  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
</IfModule> 
      

As with many of the performance optimization techniques we have discussed, there are tools to test whether you have implemented GZIP compression correctly, such as www.gziptest.com, so give it a go and start saving your users' bandwidth today!

Tags:
Brian Lynch Headshot
by Brian Lynch
Brian has a background in back-end and front-end development. He takes pride in delivering code of a high standard.
Thank you
for your inquiry!
We have received your message and will respond as soon as possible.
Thank you for contacting
LyncServe for a free consultation.
A member of our team will be in touch shortly.
Welcome to LyncServe Insight! Our latest posts on technology, design and marketing will now be delivered straight to your inbox.