Skip to main content

NetworkOnly

First added

Workbox

About

An implementation of the network only request strategy.

This class is useful if you require specific requests to only be fulfilled from the network.

If the network request fails, this will throw a SerwistError exception.

Parameters

  • pluginsPlugins to use in conjunction with this caching strategy.
  • fetchOptions — Options passed to non-navigation fetch() calls made by this strategy.
  • networkTimeoutSeconds — If set, any network requests that fail to respond within the timeout will fallback to the cache.

Usage

import { NetworkOnly, Serwist } from "serwist";

const serwist = new Serwist({
  runtimeCaching: [
    {
      matcher: ({ url }) => url.pathname.startsWith("/admin/"),
      handler: new NetworkOnly(),
    },
  ],
});

More resources

Here is a list of resources you can read to learn more about NetworkOnly: