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

mayhemer commented on this pull request.



> +         "<code>no-cache</code>".
+
+         <li><p>Set <var>revalidateRequest</var>'s
+         <a for=request>prevent no-cache cache-control header modification flag</a>.
+
+         <li><p>Set <var>revalidateRequest</var>'s <a for=request>service-workers mode</a> set to
+         "<code>none</code>".
+
+         <li>
+          <p><a>In parallel</a>, perform <a for=main>main fetch</a> using
+          <var>revalidateRequest</var>.
+
+          <p class=note>This 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. This fetch is issued in the context of a client so if it goes
+          away the request will be terminated.

Are you discussing fetch() behavior or HTTP request/response handling in general?

The initial implementation in Gecko is very simple, few unimplemented bits will be fixed as followups.  We respect SWR for any request (generally, not just for fetch() initiated requests), in any context, and even w/o a context.  There is no explicit coalescing of multiple revalidateRequests.  The revalidateRequest is not cancelled when the client (source page) is cancelled its load or otherwise goes away.

I have a followup [bug filed](https://bugzilla.mozilla.org/show_bug.cgi?id=1542322) for the cancellation bit.  The exact functionality is to be written down yet.  Cancellation in a context makes sense.  No cancellation for context-less (usually internally initiated system) requests makes sense too.

So, to answer: if there is a context, cancel.  If there is no context, don't cancel.

I personally don't see a reason why we should not respect SWR for some selected requests.  The SWR spec comes from an HTTP RFC, not fetch() spec, and doesn't way anything about context.  SWR can be generally beneficial.


-- 
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#discussion_r278983681

Received on Friday, 26 April 2019 14:53:51 UTC