Monday, December 28, 2009

Speed Up Your Page 2 - Gzip compression

OK, so almost everyone is familiar with the concept of a "zip file", right? The idea is that if you have to download a packet of information, be it a programme, big pdf, or simply some large image files, then you can compress the data into a smaller file, known as a zip file. This file is much easier and quicker to download, and then you can extract the file or files, using another programme.

A similar concept is available for your website. This is very handy when it comes to the speed of your page, because the majority of people are still using windows internet explorer as their default browser. Chrome is faster, Firefox, Opera and Safari are all much better, with good old IE being the slowest.

Barcelona SEO - Zip close up So, how can the compression work here? Well, it's known as gzip and is a universally known piece of code which you can add to your websites's htaccess file. Basically, when a browser goes to your site, they will look for this indication of whether the site is enabled as a zip, and if it is then fetch it. Your site will work perfectly fine without the gzip compression, but adding the simple piece of code can help a great deal with page loading times, not to mention bandwidth for your server - potentially saving you a load of money.

I have come across a few different snippets of code whilst researching this post (you will know I'm no programmer), but have decided to re-post a snippet of code from a google employee on a help thread. This is the code you need to add to your htaccess file:

# 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

This includes any bugs which have been known to crop up in Firefox, for example. Try it out, and de-bug in Firebug's pagespeed plugin. Let me know any comments/suggestions in the comments below guys!

Are you trying to make your website better for the search engines? Contact me at Barcelona SEO for a chat about your site. I also offer SEO Training in Barcelona if you'd prefer a more hands on approach.

No comments: