我正在使用sw-precache the the plugin为我的项目生成一个服务工作者,我可以在缓存中看到我所有的字体、js和css文件,但不能看到index / html文件,并且当我离线时它不能工作。我还收到一个“无法安装站点:未检测到匹配的服务工作者”的提示。当我尝试在应用程序清单上添加到主页时。
我的堆栈是一个通用的React + redux应用程序,其中Express + ejs用于索引文件。我不确定是不是因为我使用的是ejs而不是默认的html文件,但它似乎找不到该文件。有没有一种方法可以指定模板?我的sw-precache webpack -plugin的设置是:
new SWPrecacheWebpackPlugin({
cacheId: 'tester',
filename: 'my-service-worker.js',
directoryIndex: '/',
}),如有任何建议,不胜感激。
发布于 2017-01-11 19:45:09
插件配置中缺少缓存策略的规范。
plugins: [
new SWPrecacheWebpackPlugin({
cacheId: 'tester',
filename: 'my-service-worker.js',
runtimeCaching: [
{
urlPattern: '/',
handler: 'cacheFirst',
}
]
})
]文档:https://github.com/GoogleChrome/sw-precache#runtimecaching-arrayobject
https://stackoverflow.com/questions/41513534
复制相似问题