Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

platinum-sw-import-script not triggering SW update #92

Open
deltaepsilon opened this issue Mar 7, 2016 · 1 comment
Open

platinum-sw-import-script not triggering SW update #92

deltaepsilon opened this issue Mar 7, 2016 · 1 comment

Comments

@deltaepsilon
Copy link

The following code isn't detecting changes to /sw-alerts.js. The installs are working great—thanks to the Chrome team for the new Service Workers tab under /Resources!!!—but I'm concerned that my updates won't propagate to end users.

I'm not seeing any requests for /sw-alerts.js in the Network tab.

Removing the element solves my issue for my dev environment... but is this intended behavior?

<platinum-sw-register 
baseUri="/" 
auto-register 
clients-claim 
skip-waiting 
on-service-worker-error="handleError" 
on-service-worker-updated="handleUpdated" 
on-service-worker-installed="handleInstalled">
      <platinum-sw-offline-analytics></platinum-sw-offline-analytics>
      <platinum-sw-cache></platinum-sw-cache>
      <platinum-sw-import-script href="/sw-alerts.js"></platinum-sw-import-script>
</platinum-sw-register>
@jeffposnick
Copy link
Contributor

Under the hood, the <platinum-sw-import-script> element doesn't do very much beyond collecting all the href values into an array and passing them in as a parameter to the WorkerGlobalScope.importScripts() method.

The requests to load the scripts listed in importScripts() obey standard HTTP caching semantics, so unless you explicitly disable HTTP caching with something like a Cache-Control: response header, the next time the script is imported, it may go against the HTTP cache. Although when that does happen, you should still see a corresponding request made in the Network tab.

If you're not seeing a request made at all, then perhaps your service worker kept running in between the updates you made to your sw-alerts.js script. The importScripts() call only happens when the service worker first starts up, and I believe it won't be killed automatically in Chrome as long as you have the DevTools open. You can try explicitly stopping the service worker using that "Stop" icon in the Resources tab and then ensure that you see a request in the Network tab for sw-alerts.js once you reload your page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants