I am uploading images to S3 storage using paperclip gem. It uploads successfully.
In my application, an user can change his profile photo. If user do the profile photo change, the new image will get uploaded successfully. The problem is the browser will show previous photo only after the upload. Only after a force refresh by the hitting ctrl + F5 will the new image display.
Note: image is uploaded using form post. I guess it’s related with caching but I don’t have clue where I can change my code. Please help me this out. Thanks.
What property of your image object are you using as the
srcof your image? If you useuser.image.url(assuming that you have aUsermodel and that the Paperclip field’s calledimage) then the URL to the image on S3 should have a number in the querystring that acts to stop any caching so that you see the updated image immediately. For example the URL for the image should change fromto
which should stop the browser caching the image.