user315252
user315252

Reputation: 179

Caching dynamic images rails

In my web app each user will be having a profile image those images are stored in Amazon s3. If the user signs in i need to show that image and that will stay in the side bar in all the pages he enters. Once he signs in is there anyway i can cache the image so that i no need to get back from Amazon s3 every time ? when he again updates the image i need to clear the cache.

Upvotes: 2

Views: 792

Answers (1)

Geoff Appleford
Geoff Appleford

Reputation: 18832

You can use standard Http Caching for this.

You should set the Cache-Control and/or expires headers depending on your needs.

All the major S3 clients support setting these headers or you can set using the S3 API's or SDKs/Libraries etc.

In order to re-download the image if it has changed, you can add a querystring to the url. eg

http://mypath/myfile.ext?v=1
http://mypath/myfile.ext?v=2

Upvotes: 1

Related Questions