FEATURE: Preload resources via link header (#18475)

Experiment moving from preload tags in the document head to preload information the the response headers.

While this is a minor improvement in most browsers (headers are parsed before the response body), this allows smart proxies like Cloudflare to "learn" from those headers and build HTTP 103 Early Hints for subsequent requests to the same URI, which will allow the user agent to download and parse our JS/CSS while we are waiting for the server to generate and stream the HTML response.

Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
This commit is contained in:
Rafael dos Santos Silva
2022-10-07 13:19:50 -03:00
committed by GitHub
parent a1d67122b1
commit 2d1dbc6f96
7 changed files with 107 additions and 17 deletions

View File

@ -1124,4 +1124,16 @@ RSpec.describe ApplicationController do
end
end
end
describe 'preload Link header' do
it "should have the Link header with assets on full page requests" do
get("/latest")
expect(response.headers).to include('Link')
end
it "shouldn't have the Link header on xhr api requests" do
get("/latest.json")
expect(response.headers).not_to include('Link')
end
end
end