[w3c/ServiceWorker] consider using navigation preload response when respondWith() is not called (Issue #1611)

Currently if navigation preload is enabled, but the fetch handler does not call `respondWith()` we fallback to initiating a new request.  This results in two requests to the server.  The first navigation preload request and its response are thrown away.

You may ask, why would a service worker script do this?  The answer is that writing code to consume the navigation preload response is not obvious to new developers.  Many sites end up launching a simple "no-op" service worker in order to meet PWA installation criteria.  It seems like the double-request behavior of fallback+navpreload is a bit of a footgun.

A possible solution to this would be to implicitly call `evt.respondWith(evt.preloadResponse)` if the fetch handler returns without calling `respondWith()` explicitly.  We probably could not do this in cases where there is an extra preload header, though, as that could change the underlying content of the preload response vs what a non-preload response would see.

@jakearchibald @asutherland @youennf WDYT?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1611

Received on Wednesday, 3 November 2021 15:44:13 UTC