-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refreshing avatars #349
Refreshing avatars #349
Conversation
You could store all avatars in a folder with the user id as the name and just delete all current files in that folder before writing a new one if the avatar doesn't already exist in that folder. I like this though, refreshing the avatars would be good to add for the next release. |
Thanks for the fix, I've resolved conflicts and merged this into master. The problem with refreshing avatars is not completely fixed with this patch. |
I don't think there is any need to cache Gravatar images it self. The Since MD5 ius such a simple algorithm I wouldn't even mind to cache the |
@NobbZ do you propose to completely remove file system gravatar images cache? |
edit, original post @ the bottom! Yikes! Just see that this is the github android issuetracker… When I was writing this, and the post before, I assumed for some reason that this would be about padrino… So I leave the post for public information, but change my mind in any other way! Since we are talking about a mobile application, that probably uses an expensive dataplan, there should be extensive caching! I wouldn't mind about old gravatars, as long as the app catches up at most a day late. So I would suggest, just to cache the gravatars for about 24 hours and when they are aged, use HTTP-Header-Etag (http://en.wikipedia.org/wiki/HTTP_ETag) to check at gravatar.com if there is a new image for that given gravatar and then reset the timer and wait another 24 hours. Original post
|
I don't know about GitHub server, we are caching images in Android app's file system. |
I'm not an expert or any way other related in android programming, but as I supposed in my last post, just cache it and leave it for a couple of hours and when the cache has expired, check if the etag has changed, if yes download and cache the new version of the avatar, if not just use the old cached image. The etag is just there for this purpose. What I can't say right from the spot is if gravatar uses the etag. But they were stupid if not. |
this makes sense, I'll try this approach |
What cache headers do the gravatar servers return? The right way to cache would be to use a mechanism that simply honors traditional HTTP caching semantics. This problem has been solved for years by the underlying transport mechanism so using an HTTP client that properly honors it means that you have to do zero in-app logic. |
The etag is one of this solutions, even if it is the youngest, if it is Only trade off I realized so far is, that most http libraries I used so far But as I said already I don't have experience in android development, so I
|
OkHttp supports it. |
AvatarLoader is using HttpRequest library to download avatars. |
Hello,
This pull-request changes the way of storing avatars in the cache and fixes problem with non-refreshing avatars. Previous way was relying on userId/userEmail, so in case user changed his avatar on gravatar it had no effect in the app (it always used the cached version). Currently, avatar file is cached as Base64 string from the avatar url.
I'm wondering how to deal with old avatars. Storing all the avatars with some prefix (let's say: user_id__Base64) and deleting user_id__* before storing new one would work, but I like the idea of periodical service execution which will be maintaining cache state so it will never exceed rational limit - as the cache can contain also current avatars of the users, which are no longer active.
What's your opinion?
Best.