-
Notifications
You must be signed in to change notification settings - Fork 824
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
Missing "as" attribute in documentation on server push #1303
Comments
The problem is that we are using link headers to control the server's push behavior. However the link headers are also dasy-chained to the browser which in the case of a client that does not support H2 Push or H1 will lead to an invalid link header. If you are interested only in controlling H2 Server Push then you might add the For backwards compatibility with H1 and H2 NoPush i think that should be mentioned in the docs. |
Interesting - I had seen that change, but at the time I did not understand what it should be used for. However, I am not quite sure how to implement this. Do I just include in the above example a
|
@utrenkner the link header should look like this:
|
Note that the spec says that the element is optional.
It also says that it is appropriate to preload when:
which is what I assume makes Chrome re-fetch the resource. I think the spec is missing a piece indicating how pushes are supposed to set their |
Thank you for the clarification. As for the specs, I must admit that you are right. I had read this recent article on Smashing Magazine, which received clarification on exactly this issue by Yoav Weiss. The article says: So technically, one can omit the 'as' argument - but then one cannot expect that the browser does what one wants: To download the resource early and only once. |
I just tested |
@worenga I can confirm this. I just tried it on a test domain - here the result of WPT with IE10. |
Looking at this discussion on the W3-Preload standard, I would like to emphasize my original proposal, that we should really include the "as" attribute in the documentation. In the discussion the editors of the draft standard explain that it is de-facto required, even though it is not universally implemented this way in client software. That said, I was wondering, if we could add a feature to h2o, which would automatically map mime-types to request destinations. As @igrigorik explains, this is not in the specs. But I think it could be included in h2o, at least as a default which can be overriden. Then we would not have to include separate mruby handlers for each request destination, when we add resources to push-paths. For our site in question, we now have 4 such mruby-handlers (for style, script, image and font). |
I like this idea. |
|
Thanks to @deweerdt for the patch to the docs. And it contains a much simpler way to add several different resources types within the same mruby-handler. |
Due to my problems with pushing assets to Chrome, I learned that the "as" attribute of the preload link is not optional but required, e.g.
<link rel=preload as=script href=...>
.In the h2o documentation, this is not mentioned, see several code examples on the HTTP/2 Directives.
And the example for "Pushing asset files" given on Using Mruby must actually be written with two separate mruby-handlers - one for the CSS file with "as=style" and one for the JS file with "as=script"
The relative attribute for each content type can be found in the draft standard.
The text was updated successfully, but these errors were encountered: