1

I am using Refile to upload and serve images for my Rails 4.2.5 app and loading direct URLs to the images using Cloudfront is very slow. To the point where Heroku is continually sending me notifications of longer than usual load times for each image being loaded from route /attachments.

I have already set up Cloudfront to serve the images, and they are returning the images. The only is that when I generate a URL with Refile, I use the following:

attachment_url(object, :image, :fill, 400, 400, format: "jpg")

This is called in my product_serializer to return the URL via JSON. Then my Angular2 app uses that URL to serve the image to the front end. Everytime I hit the endpoint to get details of the product, I get a notification from Heroku with the following:

High Response Time: Heroku/wearaway-api-prod

2016-05-16 16:22:06.926
433 <158>1 2016-05-16T16:22:06.760520+00:00 heroku router - - at=info method=GET 
path="/attachments/abe2ab1fb2d141822e23f3a7f5e7e793ade6c6c8/store/fill/400/400/a248e0ab9ea3ec1adcaf1c9a01a1f0e42cd4f57c21190a7965942a8156fb/image.jpg" 
request_id=e343cc17-e4ea-4509-9f89-5b4b46ebd6f0 fwd="198.84.238.143,54.182.212.44" dyno=web.1 connect=0ms service=5928ms status=200 bytes=80505

Does anyone have an idea of how I could improve the speed of retrieving the image URLs? I might be missing something. Thanks,

Karl
  • 595
  • 1
  • 10
  • 31

0 Answers0