Cache gravatars
mdietz opened this issue · comments
Gravatars have a 300s timeout before they're evicted from the browser cache and refetched. This causes a refetched gravatar to flash in a fraction of a second after a message appears.
We should probably cache gravatars (on the client in local storage) and issue a background ajax request if the cached copy is older than 300s. If we get something other than a 304 response back from the ajax request, then do a lazy replace with the updated gravatar.
However long we change the cache to on our end will be the minimum time it takes for someone's gravatar change to propagate to the client. That's probably why they chose 5 minutes in the first place; they get an OK hit rate while ensuring that it takes no more than 5 minutes for the change to appear on a website.
I initially misunderstood this issue. I see now that you mean to cache on the client, and do some kind of background refresh when images expire.
One thing this allows us to do, btw, is update every image on the page when a gravatar changes. That's kinda neat.