enableNavigationPreload
First added
Workbox
About
If the browser supports navigation preloading, then this will enable it.
Parameters
headerValue
— Optional. Allows developers to override the value of theService-Worker-Navigation-Preload
header which will be sent to the server when making the navigation request.
Usage
import { enableNavigationPreload, NavigationRoute, NetworkFirst } from "serwist";
enableNavigationPreload();
// Swap in NetworkOnly, CacheFirst, or StaleWhileRevalidate as needed.
const navigationStrategy = new NetworkFirst({
cacheName: "cached-navigations",
});
const navigationRoute = new NavigationRoute(navigationStrategy, {
// Optionally, provide a allow/denylist of RegExps to determine
// which paths will match this route.
// allowlist: [],
// denylist: [],
});
serwist.registerRoute(navigationRoute);