Over the past year we have done lots of work in optimizing the latency for our users. There are two parts to the total latency - Server and Client Latency. While you should improve both, its important to keep in mind that 80+% of the time the user sees is on the client side after they have got the initial html back from your server. For e.g. most of our server responses will be in less than a second so if the page takes 5s to fully display over 80% is spent on client.
Livemocha also has a harder challenge in that our users are from 200 countries so a page that can be rendered quickly in US and UK maybe unacceptable in China.
The first step we took was to add hooks into our product pages to measure our response times and times to load the pages with all resources. This gave us baselines to compare with.
A good initial step to optimizing your site is to use the recommendations from YSlow and Google Page Speed Tool. Running these with your site will tell you what to do specifically.
- Good practices that we were already following were things like: Gzip resources, setting the right expires, etags, minimizing # of requests, sizes of files, minifying etc..
- At some point we had to start doing the harder things like combining resources, image sprites etc.
A lot of our efforts went into setting up the infrastructure to capture latency benchmarks and report on it. This allowed us to fix country specific issues as well. The latencies for our top pages are monitored constantly to identify issues or track improvements.
While this is still a work in progress for us, we have already made significant improvements in our site latency and the time it takes to render pages on our site.
In a nutshell:
- Setup measurement frameworks. Don't guess. You may have to home grow some parts of this based on your needs in addition to using standard tools like gomez.
- Use the recommendations of YSlow and Google pagespeed tool. E.g. This home page that has done all the optimizations that YSlow recommends: Only 1 JS, 1 CSS, image sprites etc. and the page loads quickly -even though its hosted in a different country.
- Some changes will have more bang for the buck do those first - e.g. gzip, expires headers. Doing image sprites and combining scripts are way harder. Do the easy things first.
- Adding CDN can make big difference -if you have a lot of static content. With AWS cloudfront, you can easily add this if you need to.