Prevent regeneration of S3 Signed URLs


I have an attachment functionality on my app. Users can upload Documents to S3 using Slingshot and then click a button which opens up a modal and a carousel displaying the attachments.

The downloadUrls from S3 are stored in Mongo and I have a template helper to spit them out and then an each puts them into the carousel. This all works pretty fluidly actually.

However, I want to use signed urls for better security. My issue is that clicking the button to display the modal actually creates a subtemplate each time. This subtemplate then calls a Method to create and return the signed urls. This isn’t efficient.

Ideally, I’d like for the modal and carousel to remain reactive. So that a user can upload a new document and then see it without refreshing the page. But - at the same time, I don’t want to resign a bunch of the documents again.

I was taking the route of using a Session Var and then diffing between urls to see if they’ve changed or not. But this doesn’t seem right. I must note, that the browser does cache these uploads in the carousel (they’re mostly images). So i don’t particularly care too much about the actual signed url’s expirate time.

Any ideas? I’ve read some patterns on using timefreeze to predate signed urls…so that you only recreate if it’s been > than the expiration date. However, this pattern would still make the call to the md server side and still execute the s3.getSignedUrl fn…