Question I've read the docs below but couldn't find the reason for using the "setHeaderValue" function?
navigator.serviceWorker.ready.then(registration => {
return registration.navigationPreload.setHeaderValue(newValue);
}).then(() => {
console.log('Done!');
});
Reference
I'm assuming you're already familiar with service worker navigation preloads.
To allow servers to differentiate between regular requests and navigation preload requests, browsers use the Service-Worker-Navigation-Preload header.
By default, the value of this header is true, and setHeaderValue(value) allows you to override true with something else.
This article explains it in more detail.