From 49b3a21d725c734ff81bc10d9a8623a3813a4631 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 18 Jul 2022 11:42:02 +0300 Subject: [PATCH 01/10] Define link processing for prefetch Prefetch is simply a fetch with `prefetch-src` CSP and no post-processing of the resource. Closes #5229 --- source | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/source b/source index ec68c40fa23..e54f28901d1 100644 --- a/source +++ b/source @@ -26048,15 +26048,45 @@ document.body.appendChild(wbr); link. This keyword is body-ok.

The prefetch keyword indicates that preemptively fetching and caching the specified resource is likely to be - beneficial, as it is highly likely that the user will require this resource for future - navigations. User agents must implement the processing model of the prefetch keyword described in Resource Hints. -

+ data-x="concept-fetch">fetching and caching the specified resource or same-site document is + likely to be beneficial, as it is highly likely that the user will require this resource for + future navigations.

There is no default type for resources given by the prefetch keyword.

+

The fetch and process the linked resource algorithm for prefetch links, given a link element + el, is as follows:

+ +
    +
  1. If el's href attribute's value is the + empty string, then return.

  2. + +
  3. Let options be the result of creating link options from el.

  4. + +
  5. Let request be the result of creating a + link request given options.

  6. + +
  7. Set request's destination + to "prefetch".

  8. + +
  9. Set request's initiator + to "prefetch".

  10. + +
  11. Set request's header list to « (`Sec-Purpose`, `Prefetch) ».

  12. + +
  13. The user agent should fetch request. User + agents may delay the fetching of request to prioritize othere requests that are + necessary for the current document.

  14. +
+ +

The process a link header steps for this type of linked resource are to do + nothing.

+
Link type "preload"
From 0d31016edd250cde3a8b6cf2b0321c53226f653e Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 5 Sep 2022 13:37:37 +0300 Subject: [PATCH 02/10] Null check and add Sec-Purpose definition --- source | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/source b/source index e54f28901d1..ac2cfa92ee4 100644 --- a/source +++ b/source @@ -2490,6 +2490,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • boolean
  • token
  • parameters
  • +
  • item
  • +
  • list
  • The following terms are defined in MIME Sniffing:

    @@ -26069,6 +26071,8 @@ document.body.appendChild(wbr);
  • Let request be the result of creating a link request given options.

  • +
  • If request is null, return.

  • +
  • Set request's destination to "prefetch".

  • @@ -26077,13 +26081,25 @@ document.body.appendChild(wbr);
  • Set request's header list to « (`Sec-Purpose`, `Prefetch) ».

  • + data-x="">Sec-Purpose`, `prefetch`) ».

  • The user agent should fetch request. User - agents may delay the fetching of request to prioritize othere requests that are + agents may delay the fetching of request to prioritize other requests that are necessary for the current document.

  • +

    The `Sec-Purpose` HTTP request header indicates to + the server that the resource is to be used in the future rather than immediately. + +

    The `Sec-Purpose` header field is a structured header whose value must be a list, which may contain an item whose the token `prefetch`. Its ABNF is:

    + +
    Sec-Prefetch = sf-list
    +

    The process a link header steps for this type of linked resource are to do nothing.

    From 4da1e872bb3f4bb3b6e15b29fe48e6d2174f672d Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 5 Sep 2022 17:44:07 +0300 Subject: [PATCH 03/10] Add load/error events --- source | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/source b/source index ac2cfa92ee4..182ff34a68a 100644 --- a/source +++ b/source @@ -26083,9 +26083,26 @@ document.body.appendChild(wbr); data-x="concept-request-header-list">header list to « (`Sec-Purpose`, `prefetch`) ».

    -
  • The user agent should fetch request. User - agents may delay the fetching of request to prioritize other requests that are - necessary for the current document.

  • +
  • +

    Let processPrefetchResponse be the following steps given a response response and null, failure, or a + byte sequence bytesOrNull:

    + +
      +
    1. If response is null or failure, or if response has a + non-ok status, fire an event named error at el.

    2. + +
    3. Otherwise, fire an event named load at el.

    4. +
    + +
  • + +
  • The user agent should fetch request, with + processResponseConsumeBody set to + processPrefetchResponse. User agents may delay the fetching of request to + prioritize other requests that are necessary for the current document.

  • The `Sec-Purpose` HTTP request header indicates to From 9c109a5d826b1c4b56412b6b047428bd1d2d627d Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 6 Sep 2022 08:58:44 +0300 Subject: [PATCH 04/10] Switch around ordering --- source | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source b/source index 182ff34a68a..c501a77b089 100644 --- a/source +++ b/source @@ -26068,20 +26068,20 @@ document.body.appendChild(wbr);

  • Let options be the result of creating link options from el.

  • +
  • Set request's destination to + "prefetch".

  • +
  • Let request be the result of creating a link request given options.

  • If request is null, return.

  • -
  • Set request's destination - to "prefetch".

  • -
  • Set request's initiator to "prefetch".

  • Set request's header list to « (`Sec-Purpose`, `prefetch`) ».

  • + data-x="concept-request-header-list">header list to « (`Sec-Purpose`, `prefetch`) ».

  • Let processPrefetchResponse be the following steps given a prioritize other requests that are necessary for the current document.

  • +

    The process a link header steps for this type of linked resource are to do + nothing.

    + +
    +

    The `Sec-Purpose` HTTP request header indicates to - the server that the resource is to be used in the future rather than immediately. + the server that the resource is to be used in the future rather than immediately.

    The `Sec-Purpose` header field is a structured header whose value must be a

    Sec-Prefetch = sf-list
    -

    The process a link header steps for this type of linked resource are to do - nothing.

    - -
    Link type "preload"
    From 0b4bec48ce078cf0147b5f44b177ce80b4251558 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 6 Sep 2022 09:02:43 +0300 Subject: [PATCH 05/10] Change dest --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index c501a77b089..3d8ee412ebf 100644 --- a/source +++ b/source @@ -26068,7 +26068,7 @@ document.body.appendChild(wbr);
  • Let options be the result of creating link options from el.

  • -
  • Set request's destination to +

  • Set options's destination to "prefetch".

  • Let request be the result of creating a From 7b3c15a6e19db5e385b22a10c83661d502b41e56 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 6 Sep 2022 12:30:58 +0300 Subject: [PATCH 06/10] prefetch is an initiator, not a destination --- source | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source b/source index 3d8ee412ebf..b7abdc9e4c4 100644 --- a/source +++ b/source @@ -26069,11 +26069,14 @@ document.body.appendChild(wbr); element">creating link options from el.

  • Set options's destination to - "prefetch".

  • + the empty string.

  • Let request be the result of creating a link request given options.

  • +
  • Set request's initiator to + "prefetch"..

  • +
  • If request is null, return.

  • Set request's initiator From 69771544b54c0bc0d0ef94b717b643227f47b3e1 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 30 Nov 2022 15:26:48 +0200 Subject: [PATCH 07/10] Remove header, it will be added in Fetch-Metadata --- source | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source b/source index b7abdc9e4c4..8ecee9614ed 100644 --- a/source +++ b/source @@ -26075,17 +26075,13 @@ document.body.appendChild(wbr); link request given options.

  • Set request's initiator to - "prefetch"..

  • + "prefetch".

  • If request is null, return.

  • Set request's initiator to "prefetch".

  • -
  • Set request's header list to « (`Sec-Purpose`, `prefetch`) ».

  • -
  • Let processPrefetchResponse be the following steps given a response response and null, failure, or a From f57fe195af1c018609e33dfcd2dae69ff0c73ede Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 16 Jan 2023 15:48:03 +0200 Subject: [PATCH 08/10] Fix a couple of nits --- source | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/source b/source index 8ecee9614ed..f125a15a63c 100644 --- a/source +++ b/source @@ -26069,7 +26069,7 @@ document.body.appendChild(wbr); element">creating link options from el.

  • Set options's destination to - the empty string.

  • + the empty string.

  • Let request be the result of creating a link request given options.

  • @@ -26109,18 +26109,6 @@ document.body.appendChild(wbr);
    -

    The `Sec-Purpose` HTTP request header indicates to - the server that the resource is to be used in the future rather than immediately.

    - -

    The `Sec-Purpose` header field is a structured header whose value must be a list, which may contain an item whose the token `prefetch`. Its ABNF is:

    - -
    Sec-Prefetch = sf-list
    -
    Link type "preload"
    From ff4256ac1d33a1ac9d4c51aee8125b124e450e58 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 17 Jan 2023 08:45:59 +0200 Subject: [PATCH 09/10] Fire errors only for network errors --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index f125a15a63c..1254b92299b 100644 --- a/source +++ b/source @@ -26088,8 +26088,8 @@ document.body.appendChild(wbr); byte sequence bytesOrNull:

      -
    1. If response is null or failure, or if response has a - non-ok status, fire an event named

      If response is a network error, fire an event named error at el.

    2. Otherwise, fire an event named Date: Tue, 17 Jan 2023 17:10:00 +0900 Subject: [PATCH 10/10] Small fixes --- source | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/source b/source index 1254b92299b..e26ccf4ee4e 100644 --- a/source +++ b/source @@ -2490,8 +2490,6 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

    3. boolean
    4. token
    5. parameters
    6. -
    7. item
    8. -
    9. list
    10. The following terms are defined in MIME Sniffing:

      @@ -26074,14 +26072,11 @@ document.body.appendChild(wbr);
    11. Let request be the result of creating a link request given options.

    12. +
    13. If request is null, then return.

    14. +
    15. Set request's initiator to "prefetch".

    16. -
    17. If request is null, return.

    18. - -
    19. Set request's initiator - to "prefetch".

    20. -
    21. Let processPrefetchResponse be the following steps given a response response and null, failure, or a @@ -26095,7 +26090,6 @@ document.body.appendChild(wbr);

    22. Otherwise, fire an event named load at el.

    -
  • The user agent should fetch request, with @@ -26107,8 +26101,6 @@ document.body.appendChild(wbr);

    The process a link header steps for this type of linked resource are to do nothing.

    -
    -
    Link type "preload"