docs-serwist-core-enable-navigation-preload.md
Workbox
If the browser supports navigation preloading, then this will enable it.
headerValue — Optional. Allows developers to override the value of the Service-Worker-Navigation-Preload header which will be sent to the server when making the navigation request.sw.ts
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);