workbox: Workbox doesn't cache in iOS standalone
Library Affected: workbox-sw workbox-webpack-plugin
Browser & Platform: iOS 11.4
Issue or Feature Request Description:
I trying to build a PWA that have the offline capability. I’m using workbox-webpack-plugin
with InjectManifest
class. The app runs well on Safari/Chrome (MacOS and iOS) under both online and offline condition. When I added to the app to home screen from Safari (iOS) and turn off internet connection, I got No connection
page from Safari. I tried to debug from Safari but there are no error messages.
App URL: https://nordot-pwa.herokuapp.com/ Webpack config:
new InjectManifest({
swSrc: path.resolve(paths.appSrc, "sw.js"),
swDest: "service-worker.js",
// Don't precache sourcemaps (they're large) and build asset manifest:
exclude: [/\.map$/, /^(?:asset-)manifest.*\.js(?:on)?$/]
})
Sw.js:
console.log("Service worker is running!");
workbox.skipWaiting();
workbox.clientsClaim();
workbox.routing.registerNavigationRoute("/index.html", {
whitelist: [/^(?!\/__).*/]
});
// Background sync for tracking post api
const bgSyncPlugin = new workbox.backgroundSync.Plugin("trackingQueue", {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours
});
workbox.routing.registerRoute(
/\/api\/.*\/*.json/,
workbox.strategies.networkOnly({ plugins: [bgSyncPlugin] }),
"POST"
);
workbox.precaching.precacheAndRoute(self.__precacheManifest);
When reporting bugs, please include relevant JavaScript Console logs and links to public URLs at which the issue could be reproduced.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (7 by maintainers)
There’s a bug in Safari’s service worker implementation that prevented resources loaded by
importScripts
from being implicitly cached, as the service worker specification requires.This has been fixed in Safari Technical Previews as of release 59, but I don’t know how that translates into the version of Safari that’s deployed on iOS 11.4.
My guess is that it explains what you’re seeing, and if you have access to the Safari Technical Preview program on your iOS device, confirming that the latest version of Safari works as expected should be possible.