- From: Matt Falkenhagen <notifications@github.com>
- Date: Tue, 06 Mar 2018 22:58:21 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1283/review/101822736@github.com>
mattto commented on this pull request. > - 1. Else: - 1. If <a>script resource map</a>[|url|] [=map/exists=], return <a>script resource map</a>[|url|]. - 1. Else, return a <a>network error</a>. + 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return [=service worker/script resource map=][|request|'s [=request/url=]]. + 1. If |serviceWorker|'s [=state=] is *installed*, *activating*, *activated*, or *redundant*, return a [=network error=]. + 1. Let |registration| be |serviceWorker|'s [=containing service worker registration=]. + 1. Set |request|'s [=service-workers mode=] to "`none`". + 1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true: + * |registration|'s [=service worker registration/update via cache mode=] is "`none`". + * The [=current global object=]'s [=force bypass cache for importscripts flag=] is set. + * |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. + 1. Let |response| be the result of <a lt="fetch">fetching</a> |request|. + 1. If |response|’s <a for="response" href="https://github.com/whatwg/fetch/issues/376">cache state</a> is not "<code>local</code>", set |registration|’s [=service worker registration/last update check time=] to the current time. + 1. [=Extract a MIME type=] from the |response|'s [=unsafe response=]'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. + 1. If |response|'s <a>unsafe response</a>'s [=response/type=] is not "<code>error</code>", and |response|'s [=response/status=] is an <a>ok status</a>, then: + 1. Let |newestWorker| be the result of running [=Get Newest Worker=] with |registration|. Ah I see, I think I saw the Run Service Worker algorithm being called in Install and thought that was the first time we are running the worker. > - 1. Else, return a <a>network error</a>. + 1. If |serviceWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]] [=map/exists=], return [=service worker/script resource map=][|request|'s [=request/url=]]. + 1. If |serviceWorker|'s [=state=] is *installed*, *activating*, *activated*, or *redundant*, return a [=network error=]. + 1. Let |registration| be |serviceWorker|'s [=containing service worker registration=]. + 1. Set |request|'s [=service-workers mode=] to "`none`". + 1. Set |request|'s [=request/cache mode=] to "<code>no-cache</code>" if any of the following are true: + * |registration|'s [=service worker registration/update via cache mode=] is "`none`". + * The [=current global object=]'s [=force bypass cache for importscripts flag=] is set. + * |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. + 1. Let |response| be the result of <a lt="fetch">fetching</a> |request|. + 1. If |response|’s <a for="response" href="https://github.com/whatwg/fetch/issues/376">cache state</a> is not "<code>local</code>", set |registration|’s [=service worker registration/last update check time=] to the current time. + 1. [=Extract a MIME type=] from the |response|'s [=unsafe response=]'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], return a [=network error=]. + 1. If |response|'s <a>unsafe response</a>'s [=response/type=] is not "<code>error</code>", and |response|'s [=response/status=] is an <a>ok status</a>, then: + 1. Let |newestWorker| be the result of running [=Get Newest Worker=] with |registration|. + 1. Let |resource| be null. + 1. If |newestWorker| is not null, set |resource| to |newestWorker|'s [=service worker/script resource map=][|request|'s [=request/url=]], or null if it does not [=map/exist=]. We should be able to spec it in a way that doesn't do a double download... Currently in the common case a navigation most likely will not cause a separate service worker to run for the update check. This spec change will change it so that most likely one will, so the browser will often start two service workers for a navigation. That would really impact memory/performance for us. I wouldn't worry too much about the uncommon error case causing an extra service worker to be started. -- 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/pull/1283#discussion_r172753859
Received on Wednesday, 7 March 2018 06:58:44 UTC