views:

28

answers:

2

I have a website centered around an online chat application where each user can have up to several hundred contacts. Each contact has there own profile image. I want to make it so that the contact's profile image is loaded next to there name. However, having the user download 100+ images every time they load the site seems intensive (Studies have shown that as much as 40% of users don't utilize there cache). Each image is around 60x60 pixels in dimension.

When I search on google or sign on to facebook, dozens of images are served nearly instantaneously. Beyond just having fast servers and a good connection, what are the optimal methods for delivering so many images to the user?

Possible approaches I have come up with are:

  • Storing each user's profile image in a database, constructing one image in a php file, than having the user download that, then using css to display each profile image. However, this seems extremely intense on the server and referencing such a large file so many times might take a toll on the user's browser.
  • Using nginx rather than apache to server the images (nginx generally works better to server static content such as this). However, this seems more like an optimization to a solution, rather than a solution in itself.

I am also aware that data can be delivered across persistent http connections so multiple requests do not have to be made to the server for multiple files. However, exactly how many files can be delivered across one persistent connection. Would this persistent model mean that just having the images load as separate files would not necessarily be a bad idea?

Any suggestions, solutions, and/or notes on personal experiences with relevant matters would be greatly appreciated. Scalability is extremely important here, as well as cross-browser support (IE7+, Opera, Firefox, Chrome, Safari)

EDIT: I AM NOT USING JQUERY.

+1  A: 

I recently came across this blog post that may be helpful: http://blog.teachstreet.com/homepage/how-to-use-amazon-s3-scaling-image-hosting/

Eugene Osovetsky
It's generally better to provide a summary of the information, not just a link.
Sam
Thank you for the informative blog post. Using an external host such as S3 might be a good option here. My site without the images has a very, very small file usage to user ratio. Being able to scale the images portion of the hosting separate from everything else would make things easier.
A: 

Here's a jquery plugin that delays loading images until they're actually needed (i.e., only loads images "above the fold".)

http://www.appelsiini.net/2007/9/lazy-load-images-jquery-plugin

An alternative may be to use Flash to display just the images. The advantage is Flash is a much stronger local cache that you have programm

Sam
I am not using jQuery. Flash definitely would be nice but it is something I want to avoid for greater compatibility.