Re: [w3c/ServiceWorker] Handling duplicate importScripts() (#1041)

> That seems reasonable but as part of another bug fix, I'm thinking of changing this so that the second importScripts() returns the first stored version.

I don't have a strong opinion here. But I think it'd be reasonable to align the behavior to the current `importScripts()`'s behavior in general. That is, importing the same scripts in sequence is not a special case in the other worker cases. Fetching the same worker script again may use the HTTP cache by default but it still hits the network stack. 

For service workers case, we're doing the same thing until the service worker's _imported scripts updated flag_ is set although the default cache behavior has been changed to `"no-cache"`. (It can be set to `"default"` by opting in. And the discussion around the default behavior isn't entirely over yet.) This effectively means the subsequent requests to the same script resource will replace the _script resource map_. I think it sounds fine.

> Also what should happen when a service worker recursively importScripts() itself?

Likewise, a recursion to the same script in other workers has the same behavior: Chrome encounters JS stack overflow while Firefox doesn't. It seems we should clarify the expected behavior in this case. Would we want to detect any recursion cycles along the call paths with `importScripts()`? I.e. a.js imports b.js, b.js imports c.js, and c.js imports c.js case.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1041#issuecomment-269935787

Received on Monday, 2 January 2017 05:38:21 UTC