You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [=/service worker registration=] has an associated <dfn export id="dfn-last-update-check-time">last update check time</dfn>. It is initially set to null.
204
204
205
-
A [=/service worker registration=] has an associated <dfn export id="dfn-use-cache">use cache</dfn> (a boolean). It is initially set to false.
205
+
A [=/service worker registration=] has an associated <dfn export id="dfn-update-via-cache">update via cache mode</dfn>, which is "`imports`", "`all`", or "`none`". It is initially set to "`imports`".
206
206
207
207
A [=/service worker registration=] has an associated <dfn export id="dfn-uninstalling-flag">uninstalling flag</dfn>. It is initially unset.
A {{ServiceWorkerRegistration}} object represents a [=/service worker registration=]. Each {{ServiceWorkerRegistration}} object is associated with a <dfn for="ServiceWorkerRegistration">service worker registration</dfn> (a [=/service worker registration=]). Multiple separate objects implementing the {{ServiceWorkerRegistration}} interface across documents and workers can all be associated with the same [=/service worker registration=] simultaneously.
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> |scriptURL| with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
625
631
1. Let |scopeURL| be null.
626
632
1. If |options|.{{RegistrationOptions/scope}} is <a>present</a>, set |scopeURL| to the result of <a lt="URL parser">parsing</a> |options|.{{RegistrationOptions/scope}} with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
627
-
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/useCache}}.
633
+
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/updateViaCache}}.
1. If the "<code>scope</code>" <a>target attribute</a> of the <code>Link</code> header is present, set |scopeURL| to the result of <a lt="URL parser">parsing</a> the "<code>scope</code>" <a>target attribute</a> with |scriptURL|.
1783
1789
1. Let |workerType| be the "<code>workertype</code>" <a>target attribute</a> of the <code>Link</code> header, or "<code>classic</code>" if no such attribute is present.
1784
1790
1. If |workerType| is not a valid {{WorkerType}} value, abort these steps.
1785
-
1. Let |useCache| be true if the <code>Link</code> header has a <a>target attribute</a> named "<code>usecache</code>", otherwise false.
1786
-
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, a new <a>promise</a>, null, |contextURL|, |workerType|, and |useCache|.
1791
+
1. Let |updateViaCache| be the "`updateviacache`" [=target attribute=] of the `Link` header, or "`imports`" if no such attribute is present.
1792
+
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, a new <a>promise</a>, null, |contextURL|, |workerType|, and |updateViaCache|.
1787
1793
</section>
1788
1794
1789
1795
<section>
1790
1796
<h3 id="link-element-processing">Processing the <{link}> element</h3>
1791
1797
1792
-
When a <a>serviceworker link</a>'s <{link}> element is <a>inserted into a document</a>, or a <a>serviceworker link</a> is created on a <{link}> element that is already <a>in a document tree</a>, or the <{link/href}>or <{link/scope}> attributes of the <{link}> element of a <a>serviceworker link</a> is changed, the user agent *should* run these steps:
1798
+
When a <a>serviceworker link</a>'s <{link}> element is <a>inserted into a document</a>, or a <a>serviceworker link</a> is created on a <{link}> element that is already <a>in a document tree</a>, or the <{link/href}>, <{link/scope}>, or <{link/updateviacache}> attributes of the <{link}> element of a <a>serviceworker link</a> is changed, the user agent *should* run these steps:
1793
1799
1794
1800
1. If the <{link/href}> attribute is the empty string, abort these steps.
1795
1801
1. Let |client| be the document's [=ServiceWorkerContainer/service worker client=].
1. If the <{link/scope}> attribute is present, set |scopeURL| to the result of <a lt="URL parser">parsing</a> the <{link/scope}> attribute with the <{link}> element's <a>node document</a>'s <a>document base URL</a>.
1800
1806
1. Let |workerType| be the <{link/workertype}> attribute, or "<code>classic</code>" if the <{link/workertype}> attribute is omitted.
1801
1807
1. If |workerType| is not a valid {{WorkerType}} value, <a>queue a task</a> to <a>fire an event</a> named <code>error</code> at the <{link}> element, and abort these steps.
1802
-
1. Let |useCache| be true if the <{link}>element has a <{link/usecache}> attribute, otherwise false.
1808
+
1. Let |updateViaCache| be the <{link/updateviacache}>attribute, or "`imports`" if the <{link/updateviacache}> attribute is omitted.
1803
1809
1. Let |promise| be a new <a>promise</a>.
1804
-
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s <a>creation URL</a>, |workerType|, and |useCache|.
1810
+
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s <a>creation URL</a>, |workerType|, and |updateViaCache|.
1805
1811
1. Run the following substeps <a>in parallel</a>:
1806
1812
1. Wait until |promise| settles.
1807
1813
1. If |promise| rejected, <a>queue a task</a> to <a>fire an event</a> named <code>error</code> at the <{link}> element.
1. Let |registration| be |serviceWorker|'s [=containing service worker registration=].
2298
2304
1. Set |request|'s [=service-workers mode=] to "`foreign`".
2299
2305
1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true:
2300
-
* |registration|'s [=service worker registration/use cache=] is false.
2306
+
* |registration|'s [=service worker registration/update via cache mode=] is "`none`".
2301
2307
* The [=current global object=]'s [=force bypass cache for importscripts flag=] is set.
2302
2308
* |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.
2303
2309
1. Let |response| be the result of <a lt="fetch">fetching</a> |request|.
1. If any of the strings in |scopeURL|'s [=url/path=] contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject |promise| with a <code>TypeError</code> and abort these steps.
2559
2565
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
2560
2566
1. Set |job|'s [=job/worker type=] to |workerType|.
2561
-
1. Set |job|'s [=job/use cache=] to |useCache|.
2567
+
1. Set |job|'s [=job/update via cache mode=] to |updateViaCache|.
1. If |registration|'s <a>uninstalling flag</a> is set, unset it.
2586
2592
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2587
-
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/use cache=]'s value equals |registration|'s [=service worker registration/use cache=]'s value, then:
2593
+
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
2588
2594
1. Invoke <a>Resolve Job Promise</a> with |job| and the {{ServiceWorkerRegistration}} object which represents |registration|.
2589
2595
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2590
2596
1. Else:
2591
-
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/scope url=] and |job|'s [=job/use cache=].
2597
+
1. Invoke <a>Set Registration</a> algorithm with |job|'s [=job/scope url=] and |job|'s [=job/update via cache mode=].
2592
2598
1. Invoke <a>Update</a> algorithm passing |job| as the argument.
Note: See the definition of the Service-Worker header in Appendix B: Extended HTTP headers.
2625
2631
2626
2632
1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true:
2627
-
* |registration|'s [=service worker registration/use cache=] is false.
2633
+
* |registration|'s [=service worker registration/update via cache mode=] is not "`all`".
2628
2634
* |job|'s [=force bypass cache flag=] is set.
2629
2635
* |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.
:: |updateViaCache|, an [=service worker registration/update via cache mode=]
3196
3202
: Output
3197
3203
:: |registration|, a [=/service worker registration=]
3198
3204
3199
3205
1. Run the following steps atomically.
3200
3206
1. Let |scopeString| be <a lt="URL serializer">serialized</a> |scope| with the *exclude fragment flag* set.
3201
-
1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/scope url=] is set to |scope| and [=service worker registration/use cache=] is set to |useCache|.
3207
+
1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/scope url=] is set to |scope| and [=service worker registration/update via cache mode=] is set to |updateViaCache|.
3202
3208
1. [=map/Set=]<a>scope to registration map</a>[|scopeString|] to |registration|.
0 commit comments