atomicdata-dev / atomic-data-browser

This repo is no longer used! Code is moved to Atomic-Server
https://github.com/atomicdata-dev/atomic-server/issues
MIT License
55 stars 9 forks source link

serviceworker loads html resource for home page resource #294

Open joepio opened 1 year ago

joepio commented 1 year ago

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.