Skip to content
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

Chrome reloads assets in the Link preload header #590

Closed
jdelStrother opened this issue Feb 21, 2024 · 1 comment
Closed

Chrome reloads assets in the Link preload header #590

jdelStrother opened this issue Feb 21, 2024 · 1 comment

Comments

@jdelStrother
Copy link

When using stylesheet_link_tag in Rails, it also inserts a Link: <my_stylesheet.css>; rel=preload; as=style header in the response.

This is also sent in the responses to Turbo navigations. In Chrome, this seems to trigger re-fetching the stylesheet (albeit from local cache), which then complains a few seconds later to console:

The resource http://192.168.86.25:3000/packs/css/application.css was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.

I can avoid the issue if I change my stylesheet tags to something like

stylesheet_link_tag(:application, preload_links_header: !request.headers["X-Turbo-Request-Id"])

to avoid the Link header on turbo navigation.

Think this is a dumb Chrome bug that we should just ignore? Or should turbo-rails be automatically suppressing Link headers to avoid the redundant asset load?

@afcapel
Copy link
Contributor

afcapel commented Feb 21, 2024

@jdelStrother stylesheet_link_tag is part of actionview, not of turbo-rails and we can not fix the issue here.

Can you open the issue in the main rails repo instead? Thanks!

@afcapel afcapel closed this as completed Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants