我正在尝试为一个小型静态站点设置一个简单的 Service Worker,但出现 Service Worker 控制台错误:
sw.js:59 Uncaught TypeError: workbox.expiration.CacheableResponsePlugin is not a constructor
这是在线 new workbox.expiration.CacheableResponsePlugin
任何有关如何解决此问题的建议将不胜感激。
workbox.routing.registerRoute(
/\.(?:html)$/,
new workbox.strategies.NetworkFirst({
cacheName: 'html-cache',
plugins: [
new workbox.expiration.CacheableResponsePlugin({
statuses: [0, 200],
}),
new workbox.expiration.ExpirationPlugin({
maxEntries: 50,
maxAgeSeconds: 5 * 60,
})
]
})
)
Run Code Online (Sandbox Code Playgroud) workbox ×1