Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SW Being Cached on Github Pages #272

Closed
IstoraMandiri opened this issue Jun 21, 2017 · 1 comment
Closed

SW Being Cached on Github Pages #272

IstoraMandiri opened this issue Jun 21, 2017 · 1 comment

Comments

@IstoraMandiri
Copy link

Hi, I've noticed that github pages caches the sw.js with a Cache-Control:max-age=600.

If you visit the app, and refresh the page, this cache will be extended by another 10 minutes, so if you refresh again and again every minute, the app will never update (it's always serving the cached service worker with a refreshed max-age).

I followed the guide and it does update if you leave the page open for 10+ minutes, but I can't see a way right now for forcing the SW to uncache itself.

See facebook/create-react-app#2554 SWI3

Current Config:

  OfflinePluginRuntime.install({
    onUpdating: () => {
      console.log('SW Event:', 'onUpdating');
    },
    onUpdateReady: () => {
      console.log('SW Event:', 'onUpdateReady');
      // Tells to new SW to take control immediately
      OfflinePluginRuntime.applyUpdate();
    },
    onUpdated: () => {
      console.log('SW Event:', 'onUpdated');
      // Reload the webpage to load into the new version
      if (window.confirm('A new version of the app has been pushed. Would you like to reload?')) {
        window.location.reload();
      }
    },
    onUpdateFailed: () => {
      console.log('SW Event:', 'onUpdateFailed');
    }
  });
@NekR
Copy link
Owner

NekR commented Jun 24, 2017

There is a spec being developed to solve that, but it isn't implemented anywhere yet. Also it of course won't affect browser which have ServiceWorker implemented already without that feature. So the best way to solve it is to never cache the ServiceWorker file .

@NekR NekR closed this as completed Jun 24, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants