Fix slow avatars
Created by: trevorah
Currently, we see the avatars being loaded for rooms and chat messages more often than necessary (grey placeholder avatars). This looks kinda bad on web, but it really sucks on a mobile connection. Here are the main problems:
- little to no caching: avatars from github are served with a 5 min cache header. Avatars from twitter are served with no cache header. This means that new image elements or views have to fetch the avatars from the network more often than not. This also means that if we get more efficient at having fewer views rendered, we will see more grey avatar placeholders.
-
big images: github avatars are pretty straightforward to specify the perfect size (
?s=50
), but twitter avatars are impossible. This also requires some url parsing in order to know if that query param is even supported. Big images suck for performance, especially on mobile. - avatar urls require user payloads: this is especially annoying on mobile native, as we frequently deal with room ids, but we need to fetch the room itself before we can start requesting the avatar image.
Possible solution
- "avatars.gitter.im/users/:id?s=50" and "avatars.gitter.im/communities/:id?s=50" with cache headers set to one hour. Can pipe images from github/twitter or even just redirect for now.
-
"avatars.gitter.im/rooms/:id?s=50" and even "avatars.gitter.im/messages/:id?s=50" with permanent cache headers to redirect to "avatars.gitter.im/users/:id?s=50" or "avatars.gitter.im/communities/:id?s=50".EDIT: "avatars.gitter.im/rooms/:id?s=50&toUser=:userId" as room avatars change depending on who is asking (one to ones).
@suprememoocow, @lerouxb wdyt?
Edited by 🤖 GitLab Bot 🤖