Table of Contents

Class NavigationPreloadManager

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The NavigationPreloadManager interface of the Service Worker API provides methods for managing the preloading of resources in parallel with service worker bootup.

[Value("NavigationPreloadManager")]
public class NavigationPreloadManager
Inheritance
NavigationPreloadManager
Inherited Members

Remarks

If supported, an object of this type is returned by NavigationPreload.
The result of a preload fetch request is waited on using the promise returned by PreloadResponse.

-Speed up Service Worker with Navigation Preloads (developer.chrome.com)

See also on MDN

Constructors

NavigationPreloadManager()

public NavigationPreloadManager()

Methods

Disable()

The disable() method of the NavigationPreloadManager interface halts the automatic preloading of service-worker-managed resources previously started using Enable()
It returns a promise that resolves with undefined.

[Value("disable")]
public Task<GlobalObject.Undefined> Disable()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with 'undefined'.

Remarks

The method may be called in the service worker&apos;s activate event handler (before the fetch event handler can be called).

Enable()

See also on MDN

Enable()

The enable() method of the NavigationPreloadManager interface is used to enable preloading of resources managed by the service worker.
It returns a promise that resolves with undefined.

[Value("enable")]
public Task<GlobalObject.Undefined> Enable()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with 'undefined'.

Remarks

The method should be called in the service worker&apos;s activate event handler, which ensures it is called before any fetch event handler can fire.

Disable()

See also on MDN

GetState()

The getState() method of the NavigationPreloadManager interface returns a {{jsxref("Promise")}} that resolves to an object with properties that indicate whether preload is enabled and what value will be sent in the {{HTTPHeader("Service-Worker-Navigation-Preload")}} HTTP header.

[Value("getState")]
public Task<NavigationPreloadState> GetState()

Returns

Task<NavigationPreloadState>

A Promise that resolves with an object that has the following properties:

Remarks

SetHeaderValue(string)

The setHeaderValue() method of the NavigationPreloadManager interface sets the value of the {{HTTPHeader("Service-Worker-Navigation-Preload")}} header that will be sent with requests resulting from a Windowfetch operation made during service worker navigation preloading.
It returns an empty Promise that resolves with undefined.

[Value("setHeaderValue")]
public Task<GlobalObject.Undefined> SetHeaderValue(string value)

Parameters

value string

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with 'undefined'.

Remarks

The presence of the Service-Worker-Navigation-Preload header in preloading requests allows servers to configure the returned resource differently for preloading fetch requests than from normal fetch requests.
The default directive is set to true: this method allows the possibility of configuring multiple different responses to preload requests.

NOTE

If a different response may result from setting this header, the server must set Vary: Service-Worker-Navigation-Preload to ensure that the different responses are cached.

See also on MDN