Skip to content
Snippets Groups Projects
  1. Aug 07, 2024
  2. Apr 03, 2024
    • Stan Hu's avatar
      Disable sending of Link header in preload_link_tag · 76fe184e
      Stan Hu authored
      Even though `ActionView::Helpers::AssetTagHelper.preload_links_header`
      is set to false, `preload_link_tag` sends the Link header if the total
      header size to send is under 8K. However, this causes HTTP responses
      to fail in NGINX if the default `proxy_buffer_size` is set too low.
      
      Ironically because `app/views/layouts/_loading_hints.html.haml` is a
      cached partial, `preload_link_tag` generates the HTML, but only
      actually sends the `Link` header once a minute when the cache expires.
      This suggests that the `Link` header isn't really helping much, and it
      can cause more trouble than it's worth.
      
      Rails 7.1 lowered the `preload_link_tag` limit to 1000 bytes in
      https://github.com/rails/rails/pull/48405, but that may not be
      sufficient.
      
      https://github.com/rails/rails/issues/51436 proposes to disable the
      sending of the Link header entirely. This patch does this by turning
      send_preload_links_header into a NOP.
      
      We can probably drop this patch for Rails 7.1 and up, but we might
      want to wait for https://github.com/rails/rails/pull/51441 or some
      mechanism that can disable the `Link` header.
      
      Relates to gitlab-org/gitlab#443866
      
      Changelog: fixed
      Verified
      76fe184e
Loading