DockYard / ember-service-worker

A pluggable approach to Service Workers for Ember.js
http://ember-service-worker.com
MIT License
236 stars 62 forks source link

esw + fastboot + prember #119

Closed NullVoxPopuli closed 6 years ago

NullVoxPopuli commented 6 years ago

I'm having an issue where when I refresh the page and have the dev tools closed, when I visit /chat the / route flashes first. If I have the dev tools open, /chat is what is rendered right away.

my ember-cli-build.js https://gitlab.com/NullVoxPopuli/emberclear/blob/master/packages/frontend/ember-cli-build.js

relevant bits:

 let app = new EmberApp(defaults, {
    prember: {
      enabled: isProduction,
      urls: [
        '/',
        '/faq',
        '/chat',
        '/setup',
        '/login',
      ],
    },
    'esw-index': {
      includeScope: [
        /\//,
        /\/faq(\/.*)?/,
        /\/chat(\/.*)?/,
        /\/setup(\/.*)?/,
        /\/login(\/.*)?/,
        /translations/,
      ]
    },
    'esw-cache-fallback': { patterns: ['/'], version: '1' },
  });

in my chrome dev tools, I do have "Update on reload" and "Bypass for network" checked. It seems that Bypass for network is what is allowing the correct page to be fetched upon refetch.

So, I assume that the service worker isn't fetching my prember'd /chat route? did I misconfigure something?

my dist folder looks like:

assets/...
chat/index.html
faq/index.html
...
NullVoxPopuli commented 6 years ago

I may have figured it out:

'esw-index': {
      includeScope: [
        /\/$/,
      ]
    },
    'asset-cache': {
      include:[
        'assets/**/*',
        '**/*.html'
      ]
    },

my main issue was that esw-index.includeScope says what things get the index file. I also needed a terminating $ on my root regex, because it was matching all paths.

NullVoxPopuli commented 6 years ago

Hm. Maybe not. Phones are still behaving the old way :/

NullVoxPopuli commented 6 years ago

My production site: https://emberclear.io/chat/

First time will be redirected to setup page. But once setup, it flashes the index page on load. (Even on private browsing mode)

NullVoxPopuli commented 6 years ago

I think adding a ^ to my index include received did it.

In Firefox Focus, I see correct behavior. Looks like I'm having cache busting issues with chrome. (Both: Android apps)