Google Site Speed Optimisation
I was just reading Matt Cutts blog and he reminded me about google’s site speed factors – which now (possibly) affecting page rank in search engines. This led me to jump into webmaster tools for my primary site: http://www.simple1300numbers.com.au and check its load time. Its 3.3 seconds – which according to google is in the top 50% of webpages. It also lists some suggestions on what I can do to improve it, mainly some compression to reduce transfer time.
I decided to do what I could to help the load time, so according to my own results in the Net report in firebug, it takes 4.1 seconds to load the front page.
I grabbed Page speed from the link above, here are the results and the points I address from the report:
1. Leverage browser caching
The following resources are missing a cache expiration. Resources that do not specify an expiration may not be cached by browsers. Specify an expiration at least one month in the future for resources that should be cached, and an expiration in the past for resources that should not be cached:
How to fix this? Enable caching. I use a Plesk 9.2 server, running Apache 2.2 so I found the following addition to my .htaccess
# Enable Caching # 30 days (60*60*24*30) + 1 second <FilesMatch "\.(js|css)$"> Header set Cache-Control "max-age=2592001, public" </FilesMatch> # 366 days (60*60*24*366) + 1 second <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=2592001, public" </FilesMatch>
Now I make use of a little bash script for uploading my website from development to production, it currently looks like this:
src_path=/full/path/to/dev/site/ server_ip=example.com username=example.com password=secret dst_path=/httpdocs/ lftp -c "set ftp:list-options -a; open ftp://$username:$password@$server_ip; lcd ./site; cd $dst_path; mirror --reverse --use-cache --verbose --allow-chown --allow-suid --no-umask --parallel=2 --exclude-glob .svn"
I then added to the start of the deploy script:
You will notice we don’t reference the gzip file directly up there, we do this so that the browser will fall back to the non gzip version if it doesn’t support gzip compression. Now lastly, we need to enable the compression in apache – we do this through our .htaccess
Now at this point, my Net tab in firebug tells me my load time is 2.81 seconds – I’m pretty happy with that! I will leave those changes in place and check out what webmaster is saying in a few days.
When I next get some time, I’ll check out wordpress and what plugins/hacks are available to boost its speed.