mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:01:20 +08:00
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:

committed by
GitHub

parent
a1d67122b1
commit
2d1dbc6f96
@ -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
|
||||
|
Reference in New Issue
Block a user