-
Notifications
You must be signed in to change notification settings - Fork 16
Investigate alternatives to reloadOnInstall #64
Comments
/sub |
I've played around with both approaches: You can use Unfortunately, The alternative of adding a hidden Here's the code I tested with:
I'm going to hold off on submitting a PR just yet while I explore this further, but thanks for the suggestion, @slightlyoff! |
So you're basically calling and rendering the current page twice? Can't this cause many complications (besides the performance hit)? For example:
|
|
Here's the relevant Chromium bug: https://code.google.com/p/chromium/issues/detail?id=505279 @TalAter makes a good point about unwanted side effects with the iframe trick. |
Using
<platinum-sw-register reload-on-install>
can be useful for informal integrations, as an alternative to generating a list of resources to precache. It means that as soon as the service worker is installed, the page will be reloaded, allowing a<platinum-sw-cache>
element to perform runtime caching of all the resources needed on the page.However, this forced reload can be jarring, especially since it happens at an indeterminate time (there's no guarantee about what's going to be displayed on the controlled page when the service worker finishes installing).
@slightlyoff suggested an alternative approach, in which the an instance of the controlled page is silently loaded in an
<iframe>
following the service worker installation, to trigger the same runtime caching.@wibblymat has suggested trying to determine what's already been loaded on a page. I forget the exact method he proposed used, but he can probably clarify here. Poking around a bit,
performance.getEntriesByType('resource').map(r => r.name)
might be a good start.The text was updated successfully, but these errors were encountered: