Skip to content

Commit 7c4d19c

Browse files
committed
Avoid preload if there’s no fetch listener. Fixes #1058.
1 parent d777add commit 7c4d19c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/index.bs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,6 +2872,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28722872
1. Assert: |request|'s [=request/destination=] is not "<code>serviceworker</code>".
28732873
1. If |request| is a <a>potential-navigation-or-subresource request</a>, then:
28742874
1. Return null.
2875+
1. Let |activeWorker| be |registration|'s <a>active worker</a>.
28752876
1. Else if |request| is a <a>non-subresource request</a>, then:
28762877

28772878
Note: If the non-subresource request is under the scope of a service worker registration, application cache is completely bypassed regardless of whether the non-subresource request uses the service worker registration.
@@ -2884,7 +2885,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28842885
1. Set |registration| to the result of running <a>Match Service Worker Registration</a> algorithm passing |request|'s [=request/url=] as the argument.
28852886
1. If |registration| is null or |registration|'s <a>active worker</a> is null, return null.
28862887
1. If |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, set |reservedClient|'s <a>active service worker</a> to |registration|'s <a>active worker</a>.
2887-
1. If |request| is a [=navigation request=] and |registration|'s [=navigation preload enabled flag=] is set, and |request|'s [=request/method=] is \`<code>GET</code>\`, then:
2888+
1. If |request| is a [=navigation request=] and |registration|'s [=navigation preload enabled flag=] is set, and |request|'s [=request/method=] is \`<code>GET</code>\`, and |activeWorker|'s <a>set of event types to handle</a> contains <code>fetch</code>, then:
2889+
2890+
Note: If the above is true except |activeWorker|'s <a>set of event types to handle</a> **does not** contain <code>fetch</code>, then the user agent may wish to show a console warning, as the developer's intent isn't clear.
2891+
28882892
1. Let |preloadRequest| be the result of [=request/cloning=] the request |request|.
28892893
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
28902894
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
@@ -2905,7 +2909,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29052909
1. Else if |request| is a <a>subresource request</a>, then:
29062910
1. If |client|'s <a>active service worker</a> is non-null, set |registration| to |client|'s <a>active service worker</a>'s <a>containing service worker registration</a>.
29072911
1. Else, return null.
2908-
1. Let |activeWorker| be |registration|'s <a>active worker</a>.
29092912
1. If |activeWorker|'s <a>set of event types to handle</a> does not contain <code>fetch</code>, then:
29102913
1. Return null and continue running these steps <a>in parallel</a>.
29112914
1. If |request| is a <a>non-subresource request</a>, or |request| is a <a>subresource request</a> and the time difference in seconds calculated by the current time minus |registration|'s <a>last update check time</a> is greater than 86400, invoke <a>Soft Update</a> algorithm with |registration|.

0 commit comments

Comments
 (0)