Skip to content

Commit 39ea8ff

Browse files
Opt cache.add/addAll and importScripts out of a local service worker (#1025)
* Opt cache.add/addAll and importScripts out of a local service worker * Updating to enum * Adding to v1 * “service-workers mode” * Fixing preload request. Generating html.
1 parent f1a1120 commit 39ea8ff

File tree

4 files changed

+82
-52
lines changed

4 files changed

+82
-52
lines changed

docs/index.bs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
19751975
1. If |r|'s [=request/url=]'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", then:
19761976
1. [=fetch/Terminate=] all the ongoing <a>fetches</a> initiated by |requests| with reason *fatal*.
19771977
1. Break the loop.
1978+
1. If |r|'s [=request/client=]'s [=environment settings object/global object=] is a {{ServiceWorkerGlobalScope}} object, set |request|'s [=service-workers mode=] to "`foreign`".
19781979
1. Set |r|'s [=request/initiator=] to "<code>fetch</code>" and [=request/destination=] to "<code>subresource</code>".
19791980
1. Add a {{Request}} object associated with |r| to |requestArray|.
19801981
1. Let |responsePromise| be a new <a>promise</a>.
@@ -2265,6 +2266,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
22652266
1. Let |serviceWorker| be |request|'s [=request/client=]'s [=environment settings object/global object=]'s [=ServiceWorkerGlobalScope/service worker=].
22662267
1. If |serviceWorker|'s <a>imported scripts updated flag</a> is unset, then:
22672268
1. Let |registration| be |serviceWorker|'s [=containing service worker registration=].
2269+
1. Set |request|'s [=service-workers mode=] to "`foreign`".
22682270
1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true:
22692271
* |registration|'s [=service worker registration/use cache=] is false.
22702272
* The [=current global object=]'s [=force bypass cache for importscripts flag=] is set.
@@ -2588,14 +2590,18 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
25882590

25892591
To [=fetching scripts/perform the fetch=] given |request|, run the following steps:
25902592

2593+
1. Append \`<code>Service-Worker</code>\`/\`<code>script</code>\` to |request|'s [=request/header list=].
2594+
2595+
Note: See the definition of the Service-Worker header in Appendix B: Extended HTTP headers.
2596+
25912597
1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true:
25922598
* |registration|'s [=service worker registration/use cache=] is false.
25932599
* |job|'s [=force bypass cache flag=] is set.
25942600
* |newestWorker| is not null, and |registration|'s [=last update check time=] is not null and the time difference in seconds calculated by the current time minus |registration|’s [=last update check time=] is greater than 86400.
25952601

25962602
Note: Even if the cache mode is not set to "<code>no-cache</code>", the user agent obeys Cache-Control header's max-age value in the network layer to determine if it should bypass the browser cache.
25972603

2598-
1. Set |request|'s [=skip-service-worker flag=].
2604+
1. Set |request|'s [=service-workers mode=] to "`none`".
25992605
1. If the [=fetching scripts/is top-level=] flag is unset, then return the result of [=/fetching=] |request|.
26002606
1. Append \`<code>Service-Worker</code>\`/\`<code>script</code>\` to |request|'s [=request/header list=].
26012607

@@ -2909,7 +2915,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29092915
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
29102916
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
29112917
1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`<code>Service-Worker-Navigation-Preload</code>\` and [=header/value=] is |registration|'s [=navigation preload header value=].
2912-
1. Set |preloadRequest|'s [=skip-service-worker flag=].
2918+
1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
29132919
1. Run the following substeps [=in parallel=]:
29142920
1. [=Fetch=] |preloadRequest|.
29152921

0 commit comments

Comments
 (0)