chrism
(Chris Masters)
August 12, 2015, 8:49am
1
Hi,
I’m using the paperclip gem along with the aws-sdk gem to upload images on a site hosted at heroku.
I have followed the instructions from
The images are uploading fine and it works, but I have noticed that there is a slight delay for each image and in the logs I’ve seen that each time an image is requested there seems to be some work on the server, ie
17:15:33 log.1 | [AWS S3 200 0.124315 0 retries] head_object(:bucket_name=>"my_bucket",:key=>"my_image_url")
I’ve found this issue on the paperclip repo
opened 12:18PM - 07 Jun 12 UTC
closed 04:31PM - 27 Nov 12 UTC
We are trying to optimize our views and on a page where 40 pictures are loaded w… ith the following code :
```
= image_tag(product.pictures.first.data.url(:gallery))
```
We have a load time of 840ms, if we change it to the following code :
```
= image_tag("http://bucketname.s3.amazonaws.com/products/#{product.pictures.first.id}/gallery.jpg?1325844462"
```
We become a load time of 220ms.
It means the interpolation of s3_path_url is very slow. Somebody else is expecting the same problems? For the moment I created a helper that generates my urls :
```
def picture_url(picture, style)
"http://bucketname.s3.amazonaws.com/products/#{picture.id}/#{style}.jpg"
end
```
Only problem I have here is that the cache key is not there and also the extension not.
Which seems to relate, but I was wondering if there was a best practice for this, as it seems like it would be a common issue.
Do you recommend switching out the aws-sdk gem to use fog, even though the heroku docs recommend aws-sdk.
Thanks for any advice on this!
Chris