Avatar updates for users who aren't followed by anyone

Here’s my problem.

  1. I receive a reply to a post of someone who I follow. So I fetch the actor object for whoever made the reply and store it in my database.
  2. The user who made the reply changes their avatar.
  3. I don’t receive anything because no one on my instance follows that user.
  4. When I try to load the avatar using the URL I have stored, I get a 404 because it no longer exists.

I already process the Update{Person} by first checking that the actor matches the user being updated and then simply overwrite whatever I have stored, but I don’t receive any Update activities for those users in the first place.

How does everyone else solve this?

so, mastodon does two things differently that may help:

  1. we cache all images locally for privacy reasons, which means we never have the 404 problem

  2. when receiving an activity, we refetch the user’s profile (including caching the avatar) if it’s been a few days since we’ve last done so.

the combination of these two things mean avatars never get seriously out of date, and for the time period where they are out of date, we have the last cached value to fall back on.

I cache them too now, but I do so lazily to save space so it’s still possible for the user to change the avatar after being fetched but before that URL is followed. I also delete old files from my cache. I could probably refetch the user whenever I get 404 tho :thinking: