Answer the question
In order to leave comments, you need to log in
How to organize competent caching of user avatars?
The question is obscenely stupid. Users register on the site, upload their photos, write posts. Each post stores the user id, and the link to the author's photo is generated as http://sayt.ru/user/ <userid> /photo.png
But here's the trouble - the photos of the authors, of course, are cached by the browser. And when you change someone's photo, it certainly will not be updated.
The question is - how to do these things "wisely" so that the pictures are relevant? What is the correct approach to deal with this issue?
Answer the question
In order to leave comments, you need to log in
generate a unique name for the photo each time, and store the user's ID in the link, bad practice.
The best option is a unique name for the file.
Worse option: /user/userId/photo.png?lastModify
habrahabr.ru/post/109043
www.feedthebot.com/tools/if-modified
there is this
Everything got to me!!
1. I will set up the user.lastupdate field - I will record the moment of the last profile changes.
2. When uploading a new avatar, change this lasupdate = now()
3. When issuing user posts, along with the author's id, I will also issue user.lastupdate
4. I will generate avatar url as /user/userid/photo.png?<user. last update>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question