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

[v2] [gatsby-plugin-offline] fix: improve service worker initial caching #8183

Merged
merged 6 commits into from
Sep 17, 2018
Merged

[v2] [gatsby-plugin-offline] fix: improve service worker initial caching #8183

merged 6 commits into from
Sep 17, 2018

Conversation

vtenfys
Copy link
Contributor

@vtenfys vtenfys commented Sep 15, 2018

Changes:

  • Run the onServiceWorkerActive API correctly by fixing the event handler
  • Remove the 100ms timeout for onServiceWorkerInstalled
  • Add a message API to the service worker and use this to cache initial resources, rather than using fetch after a timeout and hoping for the best
  • Cache the initial resources at onServiceWorkerActive rather than onServiceWorkerInstalled
  • Add support for handling external resources
  • Upgrade all Yarn packages, including Workbox to 3.5.0 - this is where most of the line count comes from

Note: we're currently not polyfilling Promise.all in sw-append.js - can we safely assume all browsers that support SWs also support promises?

Fixes #8145

@vtenfys
Copy link
Contributor Author

vtenfys commented Sep 15, 2018

Just need to fix one or two tests done!

Copy link
Contributor

@m-allanson m-allanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks @davidbailey00 👌

@m-allanson m-allanson merged commit 68d2fb1 into gatsbyjs:master Sep 17, 2018
@m-allanson
Copy link
Contributor

Oh I forgot to post this earlier...

can we safely assume all browsers that support SWs also support promises?

Yep, looks like it:

@KyleAMathews
Copy link
Contributor

Nice work @davidbailey00! 🙏

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

Successfully merging this pull request may close these issues.

Offline plugin sometimes has a fetch error
3 participants