Skip to content
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

Avatar caching problem using GridFS #1546

Closed
wtsarchive opened this issue Dec 2, 2015 · 3 comments
Closed

Avatar caching problem using GridFS #1546

wtsarchive opened this issue Dec 2, 2015 · 3 comments

Comments

@wtsarchive
Copy link
Contributor

Steps to reproduce:

  1. Log in as a user and go to My Account -> Change avatar
  2. Upload an avatar from computer
  3. Verify that the avatar was uploaded in a chat room
  4. Get URL of the avatar, which looks like this: /avatars/filename.jpg
  5. Make cURL request to that URL: curl -vv http://pathtochat.com/avatars/filename.jpg
  6. Make note of Last-Modified header.
  7. Repeat steps 1-6 with a different avatar file

When uploading the avatar for the second time, Last-Modified header should be updated as well, but that doesn't seem the case. Upon further investigation it seems that the uploadDate field in avatars.files collection contains the first upload date and doesn't change when uploading another avatar. This leads to caching issues with some browsers showing old avatar instead of new one, because the browser sends If-Modified-Since header and the server then responds with 304 Not Modified.

I was digging through code and it seems to me that the issue is within the GridFS itself, which doesn't update uploadDate when it overwrites files. A possible workaround would be remove the file before re-uploading it again, but I can't seem to find where exactly storing the avatar file happens in the code.

@wtsarchive
Copy link
Contributor Author

I've created a pull request for this. Tested on my machine and it worked correctly.

@rodrigok
Copy link
Member

rodrigok commented Dec 2, 2015

Closed via #1547

@rodrigok rodrigok closed this as completed Dec 2, 2015
@wtsarchive
Copy link
Contributor Author

@rodrigok Well that was quick :). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants