我可以让同步工作并清除 IndexedDB 队列,但数据没有存储在我的 mysql 数据库中。有什么我想念的吗?
我的服务人员:
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.1.1/workbox-sw.js');
// This is the "Offline copy of assets" service worker
const CACHE = "pwabuilder-offline";
const SYNC = "bgSync"
const QUEUE_NAME = "bgSyncQueue";
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.NetworkFirst({
cacheName: CACHE
})
);
const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin(QUEUE_NAME, {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours (specified in minutes)
});
workbox.routing.registerRoute(
new RegExp('^https:\/\/domain.com\/[a-zA-Z]+\/journal'),
new workbox.strategies.NetworkOnly({
plugins: [bgSyncPlugin]
}),
'POST'
);