-
Notifications
You must be signed in to change notification settings - Fork 27
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
Should JavaScript module imports respect referrer policy, and if so, how? #111
Comments
@domenic: Has this been defined in the intervening ~year? If not, @jeisinger: opinions? :) |
Nope. I tried to rope @domfarolino into doing it, but did not yet succeed :) |
Ah yes yes, thanks for the ping. I should get on this! |
So the OP has an easy situation: Deeper graphI.e., When fetching a's seems like a strange choice; either x or b seem more consistent to me. Multiple referrersConsider: <!-- x.html -->
<script type="module" src="a.js">
<script type="module" src="b.js"> // a.js
import "./c.js"; // b.js
import "./c.js"; This will fetch a and b in parallel, and whichever of them finishes being parsed first, will kick off a fetch to c.js. Which referrer should we use for c.js? In both cases, I wonder what CSS does? (With its |
CSS definitely coalesces loads of the same |
You mean that it's defined by the specification? Or that it's a thing implementations do? |
It's a thing implementations do. I don't think the spec defines it. |
I agree. I'll amend whatwg/html#9210 to not be influenced by isTopLevel.
What do we mean by "de-duplication" and "coalescing"? Are we talking about destination-specific mechanisms, like whether the CSS "infra" holds onto some map of finished requests that it can use to serve other similar requests (that might only differ by referrer policy), similar to a module script's "module map"? If so, regardless of some mechanism's explicit existence, this sounds like the memory cache which has already been acknowledge to influence requests like this (depending on whether it keys on referrer policy or not). I think the question that needs to be answered is: do any de-duplication mechanisms key based on referrer/referrer policy? It doesn't look like Chrome's memory cache does, nor HTML's "module map" (keyed by (URL, module type)), and from @emilio's comment, it sounds like CSS is happy to de-duplicate requests with different referrers/RPs, as long as their same-origin. Since it seems that we have this behavior all the way down, I'd expect all of these duplicate CSS and module script dependencies to be made with referrers and referrer policies that differ from equivalent resources in the memory cache (or destination-specific mechanism), but to be served by them anyways. It sounds like "which one makes it into the cache first" is acceptably racy, so maybe we don't have to do anything special for this case :) Thoughts? Aside: |
Yeah, it seems like a race is the de facto solution for duplicates in CSS, which seems somewhat acceptable to generalize to module scripts. |
It seems related to whatwg/fetch#1400. |
Since referrer-policy is a security mechanism, shouldn't it take into account nesting, assuming the intention of the author is described best at the top? In short, what I mean to say is - shouldn't the policy on the HTML document be enough to ban referrers for good? |
Currently the relationship everywhere (e.g. between the document and elements with |
In whatwg/html#1150 some folks decided that given
the referrer when fetching
b.js
should bea.js
, notx.html
. This apparently follows CSS, which is nice.However, we didn't think about referrer policies. It seems like if we were to follow CSS as specified in Referrer Policy, we should be checking for a Referrer-Policy header on a.js, and then falling back to x.html's referrer policy if no such header were present. Does that sound reasonable?
The text was updated successfully, but these errors were encountered: