diff --git a/fetch.bs b/fetch.bs index 70f08d11c..7dcb5d73b 100644 --- a/fetch.bs +++ b/fetch.bs @@ -41,6 +41,9 @@ url:https://tools.ietf.org/html/rfc7234#section-1.2.1;text:delta-seconds;type:df "REFERRER": { "aliasOf": "referrer-policy" }, + "STALE-WHILE-REVALIDATE": { + "aliasOf": "RFC5861" + }, "SW": { "aliasOf": "service-workers" }, @@ -1404,10 +1407,14 @@ Unless stated otherwise, it is unset.
"default" -
Fetch will inspect the HTTP cache on the way to the network. - If there is a fresh response it will be used. If there is a stale response a conditional request - will be created, and a normal request otherwise. It then updates the HTTP cache with the response. - [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]] +
Fetch will inspect the HTTP cache on the way to the network. If the HTTP cache + contains a matching fresh response it will be returned. If the HTTP cache contains a + matching stale-while-revalidate response it will be returned, and a conditional network + fetch will be made to update the entry in the HTTP cache. If the HTTP cache contains a matching + stale response, a conditional network will be created and returned to update the entry in + the HTTP cache. Otherwise, a non-conditional network fetch will be returned to update the entry + in the HTTP cache. + [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]] [[!STALE-WHILE-REVALIDATE]]
"no-store"
Fetch behaves as if there is no HTTP cache at all. @@ -1521,6 +1528,10 @@ Unless stated otherwise, it is zero. which is "basic", "cors", or "opaque". Unless stated otherwise, it is "basic". +

A request has an associated +prevent no-cache cache-control header modification flag. +Unless stated otherwise, it is unset. +

A request has an associated done flag. Unless stated otherwise, it is unset. @@ -1896,6 +1907,17 @@ is a filtered response whose

  • Return newResponse. +

    A fresh response is a response whose +age is within its freshness lifetime. + +

    A stale-while-revalidate response is a +response that is not a fresh response, and its current age is within +the stale-while-revalidate lifetime. + +

    A stale response is +a response is a response that is not a fresh response or a +stale-while-revalidate response. +

    Miscellaneous

    @@ -4151,10 +4173,11 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b `If-Range`, then set httpRequest's cache mode to "no-store". -
  • If httpRequest's cache mode is "no-cache" and - httpRequest's header list does not contain - `Cache-Control`, then append - `Cache-Control`/`max-age=0` to +

  • If httpRequest's cache mode is "no-cache", + httpRequest's prevent no-cache cache-control header modification flag + is unset, and httpRequest's header list + does not contain `Cache-Control`, then + append `Cache-Control`/`max-age=0` to httpRequest's header list.

  • @@ -4283,32 +4306,57 @@ Range Requests. [[HTTP-RANGE]] However, this is not widely supported by b
      -
    1. If storedResponse requires validation (i.e., it is not fresh), then set the - revalidatingFlag. -

    2. -

      If the revalidatingFlag is set and httpRequest's - cache mode is neither "force-cache" nor - "only-if-cached", then: - +

      If cache mode is "default" and + storedResponse is a stale-while-revalidate response, then:

        -
      1. If storedResponse's header list - contains `ETag`, then append - `If-None-Match` with its value to httpRequest's - header list. - -

      2. If storedResponse's header list - contains `Last-Modified`, then - append `If-Modified-Since` with its value to - httpRequest's header list. -

      +
    3. Set response to storedResponse. +

    4. Set response's cache state to "local". +

    5. Let revalidateRequest be a clone of request. +

    6. Set revalidateRequest's cache mode set to + "no-cache". +

    7. Set revalidateRequest's prevent no-cache cache-control header modification flag + set. +

    8. Set revalidateRequest's service-workers mode set to + "none". +

    9. In parallel perform main fetch using + revalidateRequest. + +

      Note the parallel fetch is only meant to update the state of the HTTP cache + and the response will be unused until another cache access. The stale response will be used + as the response to current request. The parallel fetch will be issued in the context of + the browsing context so if it is destroyed the request will be aborted. -

      See also the - "Sending a Validation Request" - chapter of HTTP Caching [[!HTTP-CACHING]]. +

    +
  • Otherwise: +

      +
    1. If storedResponse is a stale response, then set the + revalidatingFlag. -

    2. Otherwise, set response to storedResponse and set - response's cache state to "local". +

    3. +

      If the revalidatingFlag is set and httpRequest's + cache mode is neither "force-cache" nor + "only-if-cached", then: + +

        +
      1. If storedResponse's header list + contains `ETag`, then append + `If-None-Match` with its value to httpRequest's + header list. + +

      2. If storedResponse's header list + contains `Last-Modified`, then + append `If-Modified-Since` with its value to + httpRequest's header list. +

      + +

      See also the + "Sending a Validation Request" + chapter of HTTP Caching [[!HTTP-CACHING]]. + +

    4. Otherwise, set response to storedResponse and set + response's cache state to "local". +

    @@ -7028,6 +7076,7 @@ Clement Pellerin, Collin Jackson, Daniel Robertson, Daniel Veditz, +Dave Tapuska, David Benjamin, David Håsäther, David Orchard,