mechanikos
mechanikos

Reputation: 777

ETag usage with Amazon S3 Pre-signed URL

Use case: we have client that can download pictures from the S3 storage using pre-signed URL and periodically refresh them. We don't need to download the picture again if it has not changed. Problem: Can we use ETag and if-none-matchheader for solve our problem if pictures URL can change(e.g. after pre-signed URL expiration)?

Upvotes: 1

Views: 3714

Answers (1)

mechanikos
mechanikos

Reputation: 777

We succesfully tested using Etag with S3 Pre-signed URL. You can send Etag with if-none-match header in Pre-signed URL and receive 304 not modified if content is identical. It will works regardless of URL, e.g.

  1. You get URL that expires after 10 minutes and use it for download image.
  2. Then you save Etag of this image
  3. An hour later, when the first URL expires, you get a second URL to check whether the image has changed
  4. Now you send saved Etag in header with second URL

Upvotes: 0

Related Questions