-
Notifications
You must be signed in to change notification settings - Fork 24
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
FAQ: Why not use SRI-based caching instead? #18
Comments
What are “origins” in a browser-agnostic context? or would the approach only be addressing browsers? |
By SRI you mean what? SubResource Integrity? |
See past discussion of this idea at w3c/webappsec-subresource-integrity#22 @Mouvedia Yes. @ljharb This is an idea for browsers; for Node or other embedders, the hope might be to enable bytecode caching at all, since it doesn't have to worry about origin separation. @joyeecheung is working on this (starting with Node Core itself). |
This seems a generic issue for all modules. What makes builtin modules special here? |
@bmeck What makes this related to built-in modules is, part of the motivation for built-in modules is to reduce the overhead from downloading them over the network. Cross-origin SRI-based caching is a potential mitigation to that same download size issue, which unfortunately doesn't seem to be feasible. |
@littledan I'm still unsure I understand on why this differs from other modules, I guess I'll wait on it. The bandwidth/time savings being similar to ecosystem is fine, but I remain unclear why SRI is problematic for builtin modules. |
@bmeck (Sorry, I misunderstood your question.) Yes, you're right, cross-origin SRI-based caching faces this barrier whether or not it's caching something that's part of a built-in module polyfill. |
So, the problems I've come to understand that people have with SRI-based cross-origin caching:
I've given a lot of thought to these, and I think 1 and 2 can be reasonably mitigated by imposing a degree of randomness on the caching behavior. Basically:
However, I don't see how to mitigate 3 without double-keying, which defeats the entire point. That said, we can counter-intuitively recover most of the cross-origin benefits in a double-keyed world if we just continue to use CDNs to load libraries; if everyone gets the library from the same 3rd-party origin, then keying to that origin doesn't defeat caching. |
Hmm, I don't know what kind of math to use to understand the relationship between the "amount" of privacy preserved vs the performance degradation due to those two techniques... This reminds me a bit of checking 1/100 of the people in the airport and letting through 99% of the risk. |
@tabatkins last I checked though people don't get from the same origin and misses are pretty high, right? Wouldn't some extent of this require a kind of 'official' URL in order for that to actually work out? |
An "official" url would help, sure. But centralizing effects would occur regardless, due to the value of using the same CDN origin as others. Right now there's not any particular reason to centralize. |
@tabatkins wow I was thinking exactly the same thing. I believe the biggest problem in this whole idea is privacy. Depending on the downloads an observer system can get fair understanding of a user's browsing history. Cache poisoning: Is this a serious issue in browser contexts? Manually replacing already downloaded files is close to impossible. And a hash collision for something like this can be easily mitigated by using a better hashing algorithm? |
This idea is so frequently cited that it might be worth including in an FAQ. The idea is to use some version of signature-based SRI-based caching which crosses origins instead (with fixes for versioning and rollbacks)? This could bring the performance benefits of built-in modules, while not biasing us towards the browser-provided modules and instead deferring to the ecosystem.
There are two issues I know of to this approach:
If anyone has good references on these topics, it'd be good to include them.
cc @lukewagner
The text was updated successfully, but these errors were encountered: