fog/fog — Issue #705: Caching with signature in url
Author: gitt
Created: 2012-01-21 23:20:56+00:00
State: open

I may not 100% understand the issue here, so I'm posting in hopes of either a resolution, or maybe better understanding.

I've got a photo site, that needs to protect uploaded data stored on S3. This is done with carrierwave/fog.

```ruby
CarrierWave.configure do |config|

# Store the files locally for development
config.storage = (Rails.env.development? or Rails.env.test?) ? :file : :fog
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => 'xxxxxxxxxxxxxx',
:aws_secret_access_key => 'xxxxxxxxxxxxxx',
:region => 'us-east-1'
}
config.fog_public = false
config.fog_directory = 'xxxxxxxxxxxxxx'
config.fog_attributes = { 'Cache-Control'=>'max-age=315576000', 'Expires' => 1.week.from_now.httpdate }

end
```

The issue is that when I set fog_public to false, images are no longer cached, because the signature in the url changes. The signature appears to be generated for every request regardless of time in between. For example, you can hit a page with 50 images all images are downloaded, refresh immediately, still downloaded... This can be verified with chromes inspector, or firebug in firefox. Status code should be 304 Not Modified, but instead is 200 OK.

So, my question is: Is caching supported on private urls with s3 using fog, or should I work out other means for serving protected urls, or am I just plain doing it wrong?

Thanks!