views:

247

answers:

3

In the context of having a list of user that has an icon next to their name, is it better to cache all images of Gravatar for few minutes or it's fine to directly display the image from Gravatar? The list is around 200 users on every pages.

+3  A: 

The avatars are already cached in the browser cache so don't try to implement your own caching mechanism. But is it really necessary to display 200 avatar images on each page?

ZippyV
Well, kinda like SO with the USER page that has hundred of gravatar image isn't?
Daok
+1 for your interest in the question. I might display only the top 10 of the list... but my plan is to display for the whole list.
Daok
+2  A: 

Linking to them will be simpler and it will allow Gravatar to figure out how the caching should work. (e.g.: how long the browser cache should be?)

altCognito
+1, yes of course it would be simpler (for me) but the problem is the amount of user that is in the list, this put a lot of work on resource located somewhere else. This might slow down the page a lot?
Daok
+7  A: 

Let Gravatar do the caching. Most likely the a local isp, if not browser, would have them cached further downstream already.

Not sure how you were going to hold them on your server, but it's better web performance to load from multiple domains anyway, allows more parallel downloads.

In fact, if you cached them yourself you might do a lot more damage than good, as it's more likely someone is going to have the popular gravatars cached from a visit to some other site, SO for e.g.

dove
Maybe it's different in your location, but ISP's rarely cache afaik.
Evert
+1 for your answer. I know that Gravatar could do the caching but if the list is big, I was wondering if it's effective to do that much request.
Daok
Multiple domains = more DNS look up. each DNS look up ranges from 100 to 300 ms, and this takes up loading time.
thephpdeveloper
@Evert i believe they do, as would proxies within a corporation.
dove
@Mauris what you say is correct, though i think that time would only be true for the first lookup and not as long as you suggest. I just ran http://stackoverflow.com/users with yslow in firebug and it took 2.6 seconds, DNS lookup took < 1ms by the looks of it. I'm not ruling out this being different under different test conditions. It's not clear, without further testing, whether the gains made by parallel downloads outweigh this. It's one of the reasons SO server static content off a different domain now (though it being cookieless is the main reason)
dove
@Daok if users group is not very dynamic then a css sprite would be worth looking into, but I have a hunch that they aren't. An interesting thing to do would be to host images on amazon's cloudfront and get the benefits of a cdn, but i'd only use that for your own images and scripts (scripts that aren't available from google cdn that is). Basically I'd leave it to gravatar, I mean it's what they do, I've no doubt they implement it very well and maybe even make use of a cdn or even some tricks we're not aware of. It's their business.
dove
@dove Thank you for all extra information.
Daok