我在我的 service worker fetch 事件中列出 index.html 文档时遇到问题。因此,如果我打开一个新选项卡并转到我的开发服务器,我会在 service worker fetch 事件侦听器中看到作为请求 URL 列出的文档。
self.addEventListener("fetch", e => {
console.log(e.request.url);
});
这是输出
好的,一切都按计划进行。但是当我刷新页面时,我没有看到 index.html 的根请求或“/”。
我怎么了。我已经在我的服务器上添加了一个中间件,以确保浏览器不会缓存根文件
app.use((req, res, next) => {
if (req.url === "/") {
res.header("Cache-Control", "no-cache, no-store, must-revalidate");
res.header("Pragma", "no-cache");
res.header("Expires", 0);
}
next();
});
我快疯了,因为我无法理解发生了什么。有谁可以帮助我吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句