atomicdata-dev/atomic-data-browser

serviceworker loads html resource for home page resource

Opened this issue · 0 comments

  • Use atomic-server from this pr .
  • Open a page (on 9883, not vite)
  • Refresh the page
  • In the drive resource: Could not parse JSON from fetching http://localhost:9883. Is it an Atomic Data resource? Error message: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
  • Pressing retry or cmd+shift+r fixes the issue

This issue appeared after I basically fixed the PWA. So I guess most of the PWA is now working as intended, yay!

But it seems to return a HTML page for a JSON-AD request. I think theres some content-type stuff that needs to be applied in the cache - not sure. @Polleps do you have ideas?

In generated sw.js, we see precacheAndRoute[{ url: "index.html", revision: "8a969531351da465020b0e1390a4cca4" ...], which is probably what we want - not not for JSON-AD requests.

On a related note, I notice that the service worker caches - every single HTML request. It only needs to cache ONE html response (the root), all others should not be cached.

What makes this bug really annoying, is that it disappears when I open the dev tools. Does chrome ignore service workers when tools are open?

Precache manifest

This is probably where it's at. In vite.config.js, we specify a workbox object.

EDIT: I think I 'fixed' it by ignoring index.html. Probably disables the most important advantage (caching the HTML page), but solves the issue for now.