I wonder which solution is mostly used when fetching multiple user profile image. Especially in 'comments', which display multiple user's discussion, with their nickname and profile image.
I was saving user profile image at Firebase/profileimg/{uid}, and if a user updates the image, it replaced with new value. So only 1 profile image last per 1 user.
And if the user leave comment, I add the comment with user's current information required for comment(nickname, profileImg) together.
Because I didn't want to fetch user's info whenever I fetch each comment.
Ex)
{
author: {
uid: ****,
profileURL: 'https://...',
nickname: 'foobar'
},
body: "",
}
But the problem is, when user update their profile, photoURL of earlier comments are became obsolete, and image link is broken.
And now I am in front of 2 choices,
- keep user's old profile image alive in the storage so that the image link is still alive. (costs more storage)
- Save only user's uid in comment object and fetch the latest profile image from uid. (costs more read)
In the aspect of cost, which is more efficient or more frequently used? Thank you for reading. Waiting for senior dev guru