-
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
Expose "Save-Data" client hint in navigator.connection #42
Comments
That's a good use case. My proposal would be to expose: interface NetworkInformation : EventTarget {
readonly attribute DOMString saveData;
}; The value would contain the token communicated in the Save-Data header. Today this would yield a single value of "on", but the IETF spec does allow us to define other token values and we should support that here as well. |
I wonder if one could just get the Save-Data client hint from the outgoing Request? That may allow modification of the Request's URL if need be upon the SW fetch event on a per Request basis without the need to expose this in the API. The decision about what to store in the cache is generally made on "environmental conditions" and those are not enforceable with Save Data (unlike with something akin to Content Performance Policy). The risk is that this signal is of limited value because it's not enforceable (similar to DNT) - which may end up confusing or frustrating user who set this, but then just get ignored by sites. |
Just to clarify something from @marcoscaceres's previous comment, this information would be most useful if it were available inside of a service worker's There's no |
@igrigorik's proposed extension to NetworkInformation sounds great to me for the reason already mentioned by @jeffposnick (for SW decision making related to precaching). I can see it also being a good signal for adaptive video libraries to degrade quality somewhat to reduce network data use. |
…10365) This change introduces support for network and data-savings related checks to the Gatsby prefetcher. * If a browser supports [navigator.connection.effectiveType](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType), we will not prefetch if the user is on a connection that is effectively `slow-2g` or `2g`. As users on these connections already have constrained bandwidth, limiting this feature to `3g`, `4g` and better seems reasonable. * If a browser supports the [saveData](WICG/netinfo#42) client-hint (e.g. Chromium based browsers) and the user has indicated they prefer to save data (e.g. are on a constrained data plan), we also don't prefetch in those cases. Data Saving is primarily turned on in NBU regions and I don't anticipate this change having any negative effect for users with the feature off.
…atsbyjs#10365) This change introduces support for network and data-savings related checks to the Gatsby prefetcher. * If a browser supports [navigator.connection.effectiveType](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/effectiveType), we will not prefetch if the user is on a connection that is effectively `slow-2g` or `2g`. As users on these connections already have constrained bandwidth, limiting this feature to `3g`, `4g` and better seems reasonable. * If a browser supports the [saveData](WICG/netinfo#42) client-hint (e.g. Chromium based browsers) and the user has indicated they prefer to save data (e.g. are on a constrained data plan), we also don't prefetch in those cases. Data Saving is primarily turned on in NBU regions and I don't anticipate this change having any negative effect for users with the feature off.
The
Save-Data
client hint (described here in more detail by @igrigorik), exposes information that would be useful outside of the context of handling a HTTP request. For instance, a service worker might use the client hint to determine, as part of itsinstall
handler, whether to precache a heavy- or lightweight bundle of resources.Exposing this information from within the
NetworkInformation
interface means that a service worker and other scripts could access it vianavigator.connection
.The text was updated successfully, but these errors were encountered: