GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.22k stars 388 forks source link

runtimeCaching networkFirst doesn't work when there is any navigateFallback #312

Closed rogeriochaves closed 7 years ago

rogeriochaves commented 7 years ago

Hello, I have a sw-precache-config.js like this:

module.exports = {
  stripPrefix: "build/",
  staticFileGlobs: ["build/static/**/*.{js,css,svg}", "build/manifest.json"],
  dynamicUrlToDependencies: pagesMappings,
  navigateFallback: "index",
  runtimeCaching: [
    {
      urlPattern: "/",
      handler: "networkFirst"
    },
    {
      urlPattern: /login/,
      handler: "networkFirst"
    }
  ],
  dontCacheBustUrlsMatching: /\.(js|css)/,
  swFilePath: "build/service-worker.js"
};

I need both my root and login pages to always go to network first to see if there is a redirect from the server, and I noticed it stopped working after adding a navigateFallback, I've even added a navigateFallbackWhitelist: [/notmatchableurl/], with no luck.

The only way I got networkFirst working again was by removing navigateFallback entirely.

rogeriochaves commented 7 years ago

actually, I believe this is not the problem