-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to opt-out of sending Link header in preload_link_tag
#51441
base: main
Are you sure you want to change the base?
Conversation
d3e506a
to
662584f
Compare
662584f
to
4e94e69
Compare
This commit adds a `preload_links_header` option to `preload_link_tag` to disable sending of the Link header in the HTTP response. Currently `ActionView::Helpers::AssetTagHelper.preload_links_header` only controls whether `javascript_include_tag` and `stylesheet_link_tag` send the Link header, but there is no way to control the behavior of `preload_link_tag`. We could just check that variable, but existing applications might be relying on `preload_link_tag` to add the header. Users also might want control over this on a per call basis. Closes rails#51436
4e94e69
to
6578fbf
Compare
@@ -357,25 +357,26 @@ def preload_link_tag(source, options = {}) | |||
crossorigin = "anonymous" if crossorigin == true || (crossorigin.blank? && as_type == "font") | |||
integrity = options[:integrity] | |||
nopush = options.delete(:nopush) || false | |||
send_link_header = options.key?(:preload_links_header) ? options.delete(:preload_links_header) : true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think early_hint: false
would be a better name for this.
For our project, we have the opposite need from #51436 in response to #48405 in that we would prefer to be able to control the preload size to increase from the default 1kb. Perhaps an alternative implementation here which could satisfy all use-cases and use a single value would be a This would:
|
This commit adds a
preload_links_header
option topreload_link_tag
to disable sending of the Link header in the HTTP response.Currently
ActionView::Helpers::AssetTagHelper.preload_links_header
only controls whetherjavascript_include_tag
andstylesheet_link_tag
send the Link header, but there is no way to control the behavior ofpreload_link_tag
. We could just check that variable, but existing applications might be relying onpreload_link_tag
to add the header. Users also might want control over this on a per call basis.Closes #51436
Before submitting the PR make sure the following are checked:
[Fix #issue-number]