docs-serwist-runtime-caching-caching-strategies-cache-only.md
Workbox
An implementation of the cache only request strategy.
This class is useful if you already have your own precaching step.
If there is no cache match, this will throw a SerwistError exception.
cacheName — Cache name to store and retrieve requests. Defaults to Serwist’s default cache names.plugins — Plugins to use in conjunction with this caching strategy.fetchOptions — Options passed to non-navigation fetch() calls made by this strategy.matchOptions — The CacheQueryOptions passed to any cache.match() or cache.put() call made by this strategy.sw.ts
import { CacheOnly, Serwist } from "serwist";
const serwist = new Serwist({
runtimeCaching: [
{
matcher: ({ url }) => url.pathname.startsWith("/app/v2/"),
handler: new CacheOnly(),
},
],
});
Here is a list of resources you can read to learn more about CacheOnly: