【问题标题】:Workbox caches excluded htmlWorkbox 缓存排除的 html
【发布时间】:2018-12-22 18:30:21
【问题描述】:

如何使用 google workbox (workbox-webpack-plugin) 从 service worker 缓存中删除 index.html? 之前用的是我刚写的sw-precache-plugin

new SWPrecacheWebpackPlugin({
    dontCacheBustUrlsMatching: /\.\w{8}\./,
    filename: 'service-worker.js',
    minify: true,
    navigateFallback: '/index.html',
    staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/, /index\.html$/],
})

但它不起作用

new GenerateSW({
    cacheId: 'my-app-name',
    importWorkboxFrom: 'local',
    skipWaiting: true,
    clientsClaim: true,
    navigateFallback: '/index.html',
    exclude: [/\.map$/, /^manifest.*\.js(?:on)?$/, /\.html$/],
}),

manifest 文件中不存在 Html 文件,但每次都从 service worker 中获取。

【问题讨论】:

    标签: webpack workbox workbox-webpack-plugin


    【解决方案1】:

    你可以尝试两件事:

    1. 更新到最新的工作箱(我假设您不再需要 dontCacheBustUrlsMatching
    2. 删除navigateFallback 条目并检查它是否有效

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-06
      • 2021-09-28
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多