I am developing an architecture that needs to be rather scalable, I was am wondering how to handle my user images.
Currently, I have been storing a user’s image as a file like so:
/users/{user id}/normal.jpg
/users/{user id}/small.jpg
The problem is that I tend to run into caching issue’s with the persons’ browser e.g. when the user uploads a new image, it overwrites the normal.jpg and small.jpg, but the the user’s browse doesn’t immediately reflect the change.
Would it be better to not delete any images?
Give newly uploaded images any kind of random name, that should get rid of caching problems.
For example:
Whenever a new upload is done, remove the old one and put the new one in place. Off course you’ll need to track the actual filename somewhere in your database along with the user’s other info.