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

Cache not working on android Chrome #325

Closed shablenko closed 7 years ago

shablenko commented 7 years ago

Cache not working on android Chrome

new SWPrecacheWebpackPlugin(
            {
              cacheId: 'id',
              filename: 'service-worker.js',
              minify: true,
              mergeStaticsConfig: true,
              navigateFallback: '/index.html',
              staticFileGlobsIgnorePatterns: [/\.map$/],
              ignoreUrlParametersMatching: [/\?assests_hash/],
              staticFileGlobs: ['/'],
              runtimeCaching: [
                { urlPattern: /\/api\/file\/language/, handler: 'networkFirst' },
                { urlPattern: /\/api\/ruler/, handler: 'networkFirst' },
                { urlPattern: /\/api\/mint/, handler: 'networkFirst' },
                { urlPattern: /\/api\/state/, handler: 'networkFirst' },
                { urlPattern: /\/api\/denom/, handler: 'networkFirst' },
                { urlPattern: /\/api\/metal/, handler: 'networkFirst' }
              ]
            }
        ),
jeffposnick commented 7 years ago

Could you elaborate on what's not working—are you seeing errors in the JavaScript console, are things completely failing to load while offline, is it the runtime caching bit that's not behaving as expected, etc.?

And you mention Android Chrome—are you seeing similar issues on desktop Chrome, and desktop Firefox, or is this limited to Android Chrome? If it's just Android Chrome, what's the version number of Chrome?

shablenko commented 7 years ago

On desktop Chrome works fine, but on Android it seems like worker not caching index.html, maybe i should use absolute url to file? I cannot check console, my phone doesn`t support developer mode :(

jeffposnick commented 7 years ago

There shouldn't be any difference in service worker implementations between desktop and Android Chrome that would lead to this.

Do you use different URL schemes for your mobile site, perhaps? If so, one thing you could do to debug is to use the Device Mode Simulator of Chrome DevTools and emulate an Android device, which should be enough to trigger your mobile URL schemes. That might make it easier to debug.