Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

JS files are cached in offlineTTT instead of cacheTTT by service worker #125

Open
Seb35 opened this issue Apr 7, 2019 · 0 comments
Open

Comments

@Seb35
Copy link

Seb35 commented Apr 7, 2019

The provided service worker uses two caches: cacheTTT for static assets and bundled resources, and offlineTTT for other cached resources (with TTT a timestamp generated by Sapper).

But static assets and bundled JS resources are present in both caches:

  • in the first one when the service worker is initially populated by the 'install' event,
  • in the second one when we browse on the website.

The second one is because this condition cached.has(url.pathname) is never met because url.pathname has an initial slash (or other base URL) and the cached set is only relative to the base URL without any initial slash.

It works better (the second cache is no more populated by static assets and bundled JS resources and the service worker continues to deliver these resources) when the base URL is removed from url.pathname: cached.has(url.pathname).substring(1) where the website is on the root base URL. But I don’t know if the service worker knows its own base URL to do it programmatically without assumption on the base URL.

Seb35 added a commit to Legilibre/archeo-lex.fr that referenced this issue Apr 19, 2019
Seb35 added a commit to Legilibre/archeo-lex.fr that referenced this issue Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant