docs-serwist-runtime-caching-routing-precache-route.md
Workbox
A subclass of Route that takes a Serwist instance and uses it to match incoming requests and handle fetching responses from the precache.
serwist — A Serwist instance used to both match requests and respond to fetch events.options — Options to control how requests are matched against the list of precached URLs:
directoryIndex — Tells Serwist to check the precache for an entry whose URL is the request URL appended with the specified value. Only applies if the request URL ends with ”/“.ignoreURLParametersMatching — An array of RegExp objects matching search params that should be removed when looking * for a precache match.cleanURLs — Tells Serwist to check the precache for an entry whose URL is the request URL appended with “.html”.urlManipulation — A function that should take a URL and return an array of alternative URLs that should be checked for precache matches.sw.ts
import { Serwist } from "serwist";
const serwist = new Serwist({
// `PrecacheRoute` is automatically registered for you!
precacheEntries: self.__SW_MANIFEST,
});
serwist.addEventListeners();
Here is a list of resources you can read to learn more about PrecacheRoute: