🐛 Bug Report: Default profile picture is not cached #281

Closed
opened 2025-10-09 16:36:54 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @ItalyPaleAle on GitHub.

Originally assigned to: @kmendell on GitHub.

Reproduction steps

When invoking GET /api/users/{id}/profile-picture.png, if the user doesn't have a profile picture, the default one is generated.

However, the image is generated on every request, and this is a costly operation.

Expected behavior

The default profile picture should be cached. Ideally, it's created once when the user is created (or when another picture is deleted).

Actual Behavior

The image is generated on every request, and this is a costly operation.

Version and Environment

Current main branch

Log Output

No response

Originally created by @ItalyPaleAle on GitHub. Originally assigned to: @kmendell on GitHub. ### Reproduction steps When invoking `GET /api/users/{id}/profile-picture.png`, if the user doesn't have a profile picture, the default one is generated. However, the image is generated on every request, and this is a costly operation. ### Expected behavior The default profile picture should be cached. Ideally, it's created once when the user is created (or when another picture is deleted). ### Actual Behavior The image is generated on every request, and this is a costly operation. ### Version and Environment Current main branch ### Log Output _No response_
OVERLORD added the bug label 2025-10-09 16:36:54 +03:00
Author
Owner

@stonith404 commented on GitHub:

Yeah caching the profile picture probably would make sense. What it makes a bit difficult is that the profile picture needs to be updated when the name of a user changes.

We probably would have to add a column in the database to mark if a user has uploaded a custom profile picture. If not, the profile picture needs to be updated on every name change.

@stonith404 commented on GitHub: Yeah caching the profile picture probably would make sense. What it makes a bit difficult is that the profile picture needs to be updated when the name of a user changes. We probably would have to add a column in the database to mark if a user has uploaded a custom profile picture. If not, the profile picture needs to be updated on every name change.
Author
Owner

@kmendell commented on GitHub:

I like that approach but i think it may need some tweaking, to make it not overly engineered/complicated.

@kmendell commented on GitHub: I like that approach but i think it may need some tweaking, to make it not overly engineered/complicated.
Author
Owner

@ItalyPaleAle commented on GitHub:

There could be another way.

Every time a user is created, or there's a name change, generate the default profile image and store it in a separate folder (or instead of giving it the name of the UUID of the user, name it after the initials, such as "es.png"). We can optionally skip doing that if the user has a personal profile pic (but this isn't strictly necessary). If the image already exists (e.g. there's already "es.png" either because of Elias S. or because of Emanuela S.), you can skip re-generating this (this will need some coordination with locks etc to make sure we aren't generating the same image twice in parallel).

Those images are never deleted. Even if people change names, they can be kept around, so when another user with the same initials appear, the image already exists. This means that there may be a bit of waste, but it's negligible (in the absolute worst case, very unlikely in the real world, where you go AA..AB..AC..ZZ, you get 676 images, which is a relatively small number).

@ItalyPaleAle commented on GitHub: There could be another way. Every time a user is created, or there's a name change, generate the default profile image and store it in a separate folder (or instead of giving it the name of the UUID of the user, name it after the initials, such as "es.png"). We can optionally skip doing that if the user has a personal profile pic (but this isn't strictly necessary). If the image already exists (e.g. there's already "es.png" either because of Elias S. or because of Emanuela S.), you can skip re-generating this (this will need some coordination with locks etc to make sure we aren't generating the same image twice in parallel). Those images are never deleted. Even if people change names, they can be kept around, so when another user with the same initials appear, the image already exists. This means that there may be a bit of waste, but it's negligible (in the absolute worst case, very unlikely in the real world, where you go AA..AB..AC..ZZ, you get 676 images, which is a relatively small number).
Author
Owner

@ItalyPaleAle commented on GitHub:

Not a super-high priority, but creating this to make sure I don't forget about it either.

@ItalyPaleAle commented on GitHub: Not a super-high priority, but creating this to make sure I don't forget about it either.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-2#281