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

Blink effect #302

Closed hrasoa closed 7 years ago

hrasoa commented 7 years ago

Hi, I am building a react universal app, and on offline mode I have this issue:

issue

As you can see the fallback is rendered (home page of posts listing) before the about page. I guess the time my scripts come.

Here is the swPrecache options I use:

{
  cacheId: pkg.name,
  dontCacheBustUrlsMatching: /./,
  dynamicUrlToDependencies: {
    '/': [resolve(__dirname, '../server/views/index.ejs')]
  },
  navigateFallback: '/',
  staticFileGlobs: [
    `${publicDir}/{bundle,vendor}.*.{js,css}`
  ],
  stripPrefix: publicDir,
  runtimeCaching: [{
    urlPattern: /api/,
    handler: 'networkFirst'
  }]
}
hrasoa commented 7 years ago

Fixed by creating a /shell template with a <div id="root">Loading...</div>