Caching images with different query strings (S3 signed urls)

Posted by Brendan Long on Stack Overflow See other posts from Stack Overflow or by Brendan Long
Published on 2010-06-11T23:14:35Z Indexed on 2010/06/11 23:23 UTC
Read the original article Hit count: 181

Filed under:
|
|

I'm trying to figure out if I can get browsers to cache images with signed urls.

What I want is to generate a new signed url for every request (same image, but with an updated signature), but have the browser not re-download it every time.

So, assuming the cache-related headers are set correctly, and all of the URL is the same except for the query string, is there any way to make the browser cache it?

The urls would look something like:

http://example.s3.amazonaws.com/magic.jpg?WSAccessKeyId=stuff&Signature=stuff&Expires=1276297463
http://example.s3.amazonaws.com/magic.jpg?WSAccessKeyId=stuff&Signature=stuff&Expires=1276297500

We plan to set the e-tags to be an md5sum, so will it at least figure out it's the same image at that point?

My other option is to keep track of when last gave out a url, then start giving out new ones slightly before the old ones expire, but I'd prefer not to deal with session info.

© Stack Overflow or respective owner

Related posts about http

Related posts about caching