我正在使用 Refile 为我的 Rails 4.2.5 应用程序上传和提供图像,并且使用 Cloudfront 将直接 URL 加载到图像非常慢。以至于 Heroku 不断地向我发送通知,通知我从 route 加载的每个图像的加载时间都比平时长/attachments
。
我已经设置了 Cloudfront 来提供图像,并且他们正在返回图像。唯一的是,当我使用 Refile 生成 URL 时,我使用以下内容:
attachment_url(object, :image, :fill, 400, 400, format: "jpg")
这在我的 product_serializer 中调用以通过 JSON 返回 URL。然后我的 Angular2 应用程序使用该 URL 将图像提供给前端。每次我点击端点以获取产品的详细信息时,我都会收到来自 Heroku 的通知,其中包含以下内容:
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
有谁知道如何提高检索图像 URL 的速度?我可能会遗漏一些东西。谢谢,