GWT compiler produces code fragments as a result of code splitting (see details here)
The initial download file is named as {alphanumeric}.cache.js (e.g 1805B2053A824F148DB6D05B2186F955.cache.js) and other fragments {number}.cache.js (e.g. 1.cache.js) in the figure below.
I'm trying to develop a GWT app with Service Worker as I want the app to work offline. Once cached and offline, the GET request for initial download file triggers FETCH event in ServiceWorker but individual code fragments won't trigger the event. For some reason they seem to bypass the Service Worker.
For demonstration, check the app at https://gwt-pwa-demo.herokuapp.com/pwademo.html. It is a GWT app which uses Service Worker. It's not my app, I'm just using it for demonstration.
When you load the app, all the files will get cached. No go offline from chrome dev tools, and refresh the app. The app still shows and you will notice that initial download file is loaded from Service Worker. Now click on, Paris/Berlin/London, which will load fragments 1.cache.js and so on. Notice that these are coming from disk cache and not Cache Storage through ServiceWorker. If you look at console output, you don't see a log for these fragments which is printed from ServiceWorker Fetch event.
To clarify more, the app works offline only because the fragments are pulled from disk cache. If these fragment are not present in disk cache, the app won't work. Even if the fragments are present in Cache Storage, since ServiceWorker can't intercept these requests, they won't get loaded. Follow these steps to see this in action.
- Assuming you have loaded the app once, open dev tools -> Application -> Clear Storage and clear site data. Make sure that cache in Cache Storage is also cleared.
- Now load the app again https://gwt-pwa-demo.herokuapp.com/pwademo.html.
- The cache will be created again and you will see the fragments in the cache.
- Reload the app using "Empty Cache & Hard Reload" in Chrome while your Dev Tools are open.
- This will clear disk cache but the Cache Storage is still there.
- Go offline, and refresh the app and the initial app still loads from Cache Storage.
- But when you click on, Paris or London, which triggers loading of code fragments, it fails.

