NavigationPreloadManager: setHeaderValue() method - Web APIs | MDN

Syntax

Parameters

value

An arbitrary string value, which the target server uses to determine what should returned for the requested resource.

Return value

A Promise that resolves with undefined.

Exceptions

InvalidStateError DOMException

There is no active worker associated with the registration to which this NavigationPreloadManager belongs.

Examples

The code below demonstrates how the value might be set.

js

navigator.serviceWorker.ready
  .then((registration) =>
    registration.navigationPreload.setHeaderValue(newValue),
  )
  .then(() => console.log("Done!"))
  .catch((e) =>
    console.error(`NavigationPreloadManager not supported: ${e.message}`),
  );

Specifications

Specification
Service Workers Nightly
# dom-navigationpreloadmanager-setheadervalue

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.