Bug 238564 - Service-Worker-Navigation-Preload header not being sent when Navigation Preload is enabled.
Summary: Service-Worker-Navigation-Preload header not being sent when Navigation Prelo...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Safari 15
Hardware: Mac (Intel) macOS 12
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-30 11:53 PDT by Jeremy Wagner
Modified: 2022-04-04 10:34 PDT (History)
5 users (show)

See Also:


Attachments
Patch (7.51 KB, patch)
2022-04-04 03:52 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Wagner 2022-03-30 11:53:00 PDT
Overview:

I'm currently working on a Workbox-powered service worker for my personal website that uses streams to precache header and footer markup and combine those precached bits of markup with content partials provided by a PHP back end for faster loading performance. I'm using Navigation Preload in this mix, and have noted that the Service-Worker-Navigation-Preload header (https://developer.mozilla.org/docs/Web/HTTP/Headers/Service-Worker-Navigation-Preload) is not being sent.

This header is important for application back ends because, at least in the context of streaming partial responses, it's important to have a signal from the client that lets us know if we need to send partial content. This is where the Service-Worker-Navigation-Preload test header comes in, and it appears that Safari 15.4 (and release 142 of Safari Technical Preview) are not sending this header when Navigation Preload is enabled.

Steps to reproduce:

1. Open Safari 15.4
2. Go to Developer > Experimental Features and ensure "Service Worker Navigation Preload" is enabled.
   2a. If "Service Worker Navigation Preload" is not enabled, enable it and then restart Safari.
3. Navigate to https://jlwagner.net/
4. Click on the "contact" link to go to a page where the service worker will control it. There should be two instances of the site header and footer.
5. Navigate to https://jlwagner.net/request-headers.php to view response headers.
6. There should be a list item consisting of "HTTP_SERVICE_WORKER_NAVIGATION_PRELOAD: true", but it will not appear as the header is not being sent.
7. Open a recent version of Chrome, and repeat steps 1-4. Note that there is only one header and one footer.
8. Navigate to https://jlwagner.net/request-headers.php to view response headers.
9. Note that a list item consisting of "HTTP_SERVICE_WORKER_NAVIGATION_PRELOAD: true" is present.

Expected results:

The Service-Worker-Navigation-Preload header is not being sent when Navigation Preload is enabled.

Actual results:

The Service-Worker-Navigation-Preload header should be sent when Navigation Preload is enabled.

Build Date & Hardware:
Safari Version 15.4 (17613.1.17.1.6) on macOS 12.3 (Intel)

Additional information:
Web Platform Test for the header shows a failure for Safari Technical Preview: https://wpt.fyi/results/service-workers/service-worker/navigation-preload/request-headers.https.html?label=experimental&label=master&aligned
Comment 1 youenn fablet 2022-04-04 03:52:06 PDT
Created attachment 456555 [details]
Patch
Comment 2 youenn fablet 2022-04-04 09:45:30 PDT
Comment on attachment 456555 [details]
Patch

iOS w2 failure is unrelated
Comment 3 EWS 2022-04-04 10:33:05 PDT
Committed r292296 (249194@main): <https://commits.webkit.org/249194@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 456555 [details].
Comment 4 Radar WebKit Bug Importer 2022-04-04 10:34:26 PDT
<rdar://problem/91248490>