I work on an old application that used ApplicationCache to work offline. Because of its deprecation, we would like to move to Service Workers to achieve the same goal.

Firefox 67 works very well with my current service worker implementation: when I first access to the application, every file listed as 'to-be-cached' is effectively downloaded and cached. The app can then be accessed offline.

Nevertheless, Chrome 74 and Android WebView (which looks like to be based on Chrome 73 - inside a Cordova app) have a slightly different comportment. When I first access to the application, a request per 'to-be-cached' file is put inside the cache. Navigating through the app works great when I'm online. But then I switch offline and only pages I have already accessed to are now accessible.

Is this a bug or a feature? Whatever it is, is there any workaround?

1 Answers

1
Abrikot On Best Solutions

Finally, here is what I have understood: Firefox compares cached resources on their URLs (string). Thus, giving a list of URLs (string) is sufficient for Firefox to cache them and retrieve them later with a Request object (sent when browsing the web application).

Chrome apparently compares cached resources on another value (I haven't managed to find which one). Then, giving a list of URLs (string) wasn't sufficient for Chrome. Request objects and URLs (string) were not recognized as the same.

Based on W3C's specification cache.addAll method, Chrome behaviour should be the right one. But Firefox behaviour is simplier.