Reputation: 273
I am having trouble listing index.html document in my service worker fetch event. So if I open a new tab and go to my development server I see the document listed as a request URL in service worker fetch event listener.
self.addEventListener("fetch", e => {
console.log(e.request.url);
});
and here is the output
Okay everything working as planned. But when I do a refresh of the page I don't see the root request or "/" for index.html.
What I going on. I have already added a middleware on my server to ensure that the browser won't cache the root file
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();
});
So here is the output after the first refresh
I am going nuts because I cannot understand what is going on. Can someone help me, please?
Upvotes: 1
Views: 294
Reputation: 56074
You might be running into issues due to the request for /index.html
(or /
) being a navigation, and the browser's DevTools resetting the console log messages following a navigation.
In Chrome's DevTools, I'd recommend going to the Network tab, and checking the "Preserve log" box there:
Upvotes: 2