sw-precache-webpack
使用content-type text/html
我正在将sw-precache-webpack-plugin与Webpack Manifest插件一起使用,以生成服务工作者来预缓存静态资产。
当我将其部署到Firebase时,它工作正常。服务人员使用正确的内容类型缓存静态内容。
但是,当从(https://content.new.com/tv)的子目录提供服务时 服务工作者使用错误的内容类型text / HTML缓存所有内容(图像,js)
这是sw-precache-webpack-plugin配置
new SWPrecacheWebpackPlugin({
// By default, a cache-busting query parameter is appended to requests
// used to populate the caches, to ensure the responses are fresh.
// If a URL is already hashed by Webpack, then there is no concern
// about it being stale, and the cache-busting can be skipped.
dontCacheBustUrlsMatching: /\.\w{8}\./,
filename: 'service-worker.js',
logger(message) {
if (message.indexOf('Total precache size is') === 0) {
// This message occurs for every build and is a bit too noisy.
return;
}
console.log(message);
},
minify: true, // minify and uglify the script
navigateFallback: '/index.html',
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/, /\.html$/],
})
我是sw-precache的新手,将不胜感激。