Add race-network-and-cache source to static routing api. #1764
Add race-network-and-cache source to static routing api. #1764
Conversation
|
@yoshisatoyanagisawa PTAL when you get a chance, thanks! |
|
@sisidovski Will you take a look? |
3305a7f to
3ff30ad
Compare
|
@yoshisatoyanagisawa Can you please review the recent changes - removed networkFetchCompleted and fetchHandlerCompleted that was introduced in the PR earlier and incorporated timingInfo per the recent changes in the cache/race-network-and-cache algorithm. |
|
Thanks for the contribution. Overall it looks good except the raceNetworkAndCacheCacheName source support. |
59f6074 to
9260716
Compare
|
@youennf @asutherland FYI Thanks @monica-ch for addressing the comments, the PR looks good to me. |
|
@youennf @asutherland What do you think of this change? |
|
I haven't looked at the PR, a few thoughts/questions:
|
|
Thank you for sharing your thoughts/questions @youennf I think the Resource Timing API should also be updated to help web developers to use the API properly.
If the elapsed time between
I think this can be guessed from the resource timing API. Especially seeing the workerFinalRouterSource ratio.
Since ServiceWorkerAutoPreload has been around for a while, there may not actually be much resistance to racing, but I think the current cache behavior will leave web developers with an explicit choice to prioritize the cache. i.e. no network access if the cache is available.
I think this is the equivalent attack surface with the fetch handler. The service worker static routing API is offloading of the traditional fetch handler. We keep this offloading principle as much as possible. With the race-network-and-cache, the web application can guess the user's device situation like disk access performance and network access performance. However, the same thing can be done with the fetch handler. |
If decision is made this way, that would require reinstalling the service worker whenever a website wants to opt-in/out of racing. This seems inadequate as the usefulness of racing may depend on varying network conditions. I would have expected that racing could be enabled/disabled without the need to reinstall the service worker.
It can be guessed but not known for sure, especially if the UA is disabling racing in some specific cases (5G metered vs. wifi for instance).
Not with the same precision. A fetch handler adds JS, different IPC messages and so on. |
|
Thanks for the follow-up. I feel I might not have addressed your points clearly in my previous response, so let me clarify my perspective on each. Regarding the opt-in/out of racing and SW reinstallation: In my view, the decision to use racing is less about varying network conditions and more about whether the server-side is willing to accept the additional load. The motivation of the feature is that developers opt for Regarding different strategies for different routes: A potential use case for route-specific strategies would be a "niche" optimization where a developer races resources critical to LCP (Largest Contentful Paint) to ensure they arrive as fast as possible, while relying solely on the cache for other resources to reduce server pressure—even if those resources take slightly longer to load. Regarding the UA disabling racing (e.g., 5G metered vs. Wi-Fi): I understand your point now. I was previously thinking about how developers use the Resource Timing API to send data to the server for research and statistics. From that perspective, it's discernible on the server side. However, if you are referring to the web app knowing this on the client side, I’m not sure what behavior the app would change based on that information. Beyond server-side statistics, what specific use cases do you have in mind for the client-side web app? Regarding precision: While I agree that bypassing the fetch handler reduces "noise" from JavaScript and IPC, I’m not sure how impactful that is compared to the much larger noise inherent in network or HDD access. In terms of measurement precision, both approaches use the same underlying timers, so the results should be comparable. If you believe the precision difference is significant, I would appreciate more details on that. |
This PR adds new source
race-network-and-cacheto the SW static routing api per https://github.com/WICG/service-worker-static-routing-api/blob/main/final-form.md.Preview | Diff