-
Notifications
You must be signed in to change notification settings - Fork 6
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
Subsequent subresource requests' sources follow the navigation request's source. #7
Comments
Would prefer to keep the flexibility to do both though. I can see a site wanting to start using service workers to speed up or improving caching of static resources, but want to roll this out without affecting the perf of the initial navigation. |
Allowing both sounds reasonable to me. At the same time, if we follow Service worker scope's mental model, such inheriting behavior should always starts from navigation request and subresource request cannot start that. From that perspective, I prefer adding a sourceUrlPattern condition (this sounds only applicable to navigation request) to allowing a rule to decide. |
Sry, not sure I got which option you are recommending 1) navigation rule decides for all subresource, or 2) individual subresource rule can decide using a source regex. You mention sourceUrlPattern which makes me think of #2, but you also mention "this sounds only applicable to navigation request". re: SW scope mental model, it seems that we are already outside of that here. Since the router acts on a per request basis, not a per navigation basis (unlike SW scope which works only on the navigation). So for this reason, I think it makes sense to continue that model here and say requests are always independent, but devs can create a request rule that is conditional on the originating page. |
For ease of understanding a rule at a glance, I think making rules independent better, and I am leaning on 2) individual subresource rule can decide using a source URLPattern. I understand this is a bit different from the SW scope mental model, though. Also, 1) navigation rule decides for all subresource might not be easy to write in the static routing API rules. |
+1 |
I was asked for my opinion on this issue, but I don't think I understand it very well. In particular, I don't understand the proposals people are making, or what different code they would result in.
Hmm. I don't understand this natural expectation, personally. If my router says to only handle |
I can provide a practical example here:
It would be useful to configure the static routing to skip the service worker for all static resources fetched by the applications that don't support offline. |
I see, so this is proposing to add a "dynamic routing" mode to the router, where the treatment of a URL is no longer based on static routes, but instead based on what initiator URL caused the fetch? I wonder how that works when multiple initiators request the same subresource, e.g. with multiple tabs open controlled by the same service worker... |
Yes, but I wouldn't call it dynamic, since these are still conditions captured and executed by the browser, rather than decided on demand by app-provided js when the fetch happens. |
When we consider the use case like using the static routing API as compliment to the ServiceWorker scope, it should be natural to make the subsequent subresource requests follow the navigation request's source. It means that if the navigation request's source is "network", the subsequent requests also goes "network".
For example, if a developer does not want "/form/*" to use ServiceWorker, it is natural expectation to avoid using ServiceWorker for images or scripts imported from there even if the images or the scripts are out of "/form/*". It brings the same mental model with the ServiceWorker scope.
The text was updated successfully, but these errors were encountered: