heroku - Caching signed S3 URI's with paperclip and rails -


i'm generating expiring signed uri's paperclip on s3. on every request generate new uri not ideal , forces browser download new set of images s3 on every page refresh.

what i'd cache generated uri's little less time expire on s3. has done before , can suggest solution.

i'm deploying on heroku if suggests solution ( or not )

there easy way quite neat. paperclip expiring_url method takes explicit time. can like

  def s3_expiry         time.zone.now.beginning_of_day.since 25.hours   end 

and when need expiring url

 user.avatar.expiring_url(s3_expiry, :thumb) 

the trick image expired in s3 @ end of day + 1 hour url generated until end of day. new url's generated @ 12:00 midnight every night. prevents images being used off site more 25 hours should enough prevent rampant hot linking still enough allow browsers cache images day


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -