BackgroundSyncPlugin
First added
Workbox
About
A class implementing the fetchDidFail
lifecycle callback. This makes it easier to add failed requests to a background sync queue
.
Parameters
See BackgroundSyncQueue’s parameters.
Usage
import { BackgroundSyncPlugin, NetworkOnly } from "serwist";
const backgroundSync = new BackgroundSyncPlugin("myQueueName", {
maxRetentionTime: 24 * 60, // Retry for a maximum of 24 Hours (specified in minutes)
});
serwist.registerCapture(
/\/api\/.*\/*.json/,
new NetworkOnly({
plugins: [backgroundSync],
}),
"POST",
);