-
Notifications
You must be signed in to change notification settings - Fork 22k
Closed
Closed
Copy link
Labels
Description
Steps to reproduce
- Install a S3 backend according the guide
- Upload a file
Expected behavior
Store the variant also in the DB so it does not need a extra roundtrip to the S3 backend because it takes a lot of extra time and a payed hit on the S3 API.
Actual behavior
When a variant file is displayed with image_tag @medium.object.variant(resize: "100x100")
it creates a temporary redirect link. When the link is accessed it checks in de backend if the file exists it redirect to this if not it creates one (expected) for the first time. Why does it needs to check the second time the backend again to verify if the file is there?
System configuration
Rails version: 5.2.0
Ruby version: 2.5.1
See the S3 extra time of 248ms which can be saved by storing also the variant in the DB.
Started GET "/rails/active_storage/representations/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--7bedf6cf1d85f143fa1cf3114ea2bc1d07ebfd5d/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lNTVRBd2VERXdNQVk2QmtWVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--858057ffe36ceadc4c3ef7a7e88828f422043320/01508_paradise_1920x1080.jpg" for ::1 at 2018-04-12 18:13:14 +0200
Processing by ActiveStorage::RepresentationsController#show as JPEG
Parameters: {"signed_blob_id"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBDUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--7bedf6cf1d85f143fa1cf3114ea2bc1d07ebfd5d", "variation_key"=>"eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCam9MY21WemFYcGxTU0lNTVRBd2VERXdNQVk2QmtWVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--858057ffe36ceadc4c3ef7a7e88828f422043320", "filename"=>"01508_paradise_1920x1080"}
ActiveStorage::Blob Load (0.3ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 4], ["LIMIT", 1]]
↳ vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.0/lib/active_record/log_subscriber.rb:98
S3 Storage (248.4ms) Checked if file exists at key: variants/3FKExTkgi1Y2TKQVxauWFL7Q/4ee1aeed96ebbe10c358175ed0e35ee3865e7ff1f5fdac3eb240725f48e4cb91 (yes)
S3 Storage (4.2ms) Generated URL for file at key: variants/3FKExTkgi1Y2TKQVxauWFL7Q/4ee1aeed96ebbe10c358175ed0e35ee3865e7ff1f5fdac3eb240725f48e4cb91 (https://rails-test-js.s3.eu-central-1.amazonaws.com/variants/3FKExTkgi1Y2TKQVxauWFL7Q/4ee1aeed96ebbe10c358175ed0e35ee3865e7ff1f5fdac3eb240725f48e4cb91?response-content-disposition=inline%3B%20filename%3D%2201508_paradise_1920x1080.jpg%22%3B%20filename%2A%3DUTF-8%27%2701508_paradise_1920x1080.jpg&response-content-type=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJEACUYOCFDPEQYCA%2F20180412%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20180412T161315Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=8d0317910080b4513bc5fe96b8c17a78c7b847762718a9e6efbdbd49d61e4b1f)
Redirected to https://rails-test-js.s3.eu-central-1.amazonaws.com/variants/3FKExTkgi1Y2TKQVxauWFL7Q/4ee1aeed96ebbe10c358175ed0e35ee3865e7ff1f5fdac3eb240725f48e4cb91?response-content-disposition=inline%3B%20filename%3D%2201508_paradise_1920x1080.jpg%22%3B%20filename%2A%3DUTF-8%27%2701508_paradise_1920x1080.jpg&response-content-type=image%2Fjpeg&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJEACUYOCFDPEQYCA%2F20180412%2Feu-central-1%2Fs3%2Faws4_request&X-Amz-Date=20180412T161315Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=8d0317910080b4513bc5fe96b8c17a78c7b847762718a9e6efbdbd49d61e4b1f
Completed 302 Found in 257ms (ActiveRecord: 0.3ms)
MarkMurphy, travisp, nicolasmlv, kirillsalikhov, 3pns and 7 more