Re: [whatwg/fetch] Add Stale While Revalidate Handling (#853)

jakearchibald requested changes on this pull request.



> @@ -1410,9 +1413,11 @@ Unless stated otherwise, it is unset.
  <dl>
   <dt>"<code>default</code>"
   <dd><a for=/>Fetch</a> 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]]
+  If there is a fresh response it will be used. If there is a <a>stale response inside revalidate window</a>
+  and the request has the <a for=request>stale content mode</a> set it will be returned
+  immediately. If there is a <a>stale response</a> a conditional request will be created and the
+  response will update the HTTP cache. Otherwise, a normal network request will be issued.

I still think this could be clearer (given it's non-normative).

If we had definitions like:

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

A **stale-while-revalidate response** is a response that isn't a *fresh response*, but it's current age is within its stale-while-revalidate lifetime.

A **stale response** is a response that isn't a *fresh response* or a *stale-while-revalidate response*.

("freshness lifetime" and "stale-while-revalidate lifetime" should be linked to something which defines those calculations)

Then, the "default" can be described as:

1. If the HTTP cache contains a matching *fresh response* it will be returned.
1. 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.
1. If the HTTP cache contains a matching *stale response*, a conditional network fetch will be returned.
1. Otherwise, a non-conditional network fetch will be returned.

> @@ -1526,6 +1531,10 @@ Unless stated otherwise, it is zero.
 which is "<code>basic</code>", "<code>cors</code>", or "<code>opaque</code>".
 Unless stated otherwise, it is "<code>basic</code>".
 
+<p>A <a for=/>request</a> has an associated <dfn export for=request id=stale-content-mode>stale content mode</dfn>,
+which is "<code>allow</code>", "<code>disallow</code>" or "<code>default</code>". Unless stated
+otherwise, it is "<code>default</code>".

If the only difference between "no-cache" and a SWR update request is the SWR update request doesn't add the `Cache-Control: max-age: 0` header, should we just add a flag to prevent that step?

> @@ -1901,6 +1910,13 @@ is a <a>filtered response</a> whose
  <li><p>Return <var>newResponse</var>.
 </ol>
 
+<p>A <dfn export id=concept-stale-response>stale response</dfn> is a <a for=/>response</a> where
+the freshness lifetime calculation (excluding the stale-while-revalidate directive) has not
+exceeded the current age.

We shouldn't call a fresh response a "stale response".

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/853#pullrequestreview-208456993

Received on Wednesday, 27 February 2019 11:16:14 UTC