-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-plugin-offline): reload when missing resources and SW was updated + add "onServiceWorkerUpdateReady" API #10432
feat(gatsby-plugin-offline): reload when missing resources and SW was updated + add "onServiceWorkerUpdateReady" API #10432
Conversation
…new API for updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from a docs perspective. This can get merged after a technical review from anyone else on the OSS team!
@pieh (summary of what I said on Slack): the current API |
@pieh this site https://www.mahmago.com/ is a good example of why we need a separate API - upon first visit it says "this site has updated" |
|
||
return cachedResponse | ||
}) | ||
return caches.match(offlineShell, { cacheName }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's safe to remove that yet. This handles stuff before runtime actually run, so we can't really rely that any changes we make in runtime are actually in effect (not to mention that people can use "missmatched" versions of gatsby and offline plugin in this could "brick" their sites still in those still not figured out scenarios)
`onServiceWorkerUpdateFound`を使うようにドキュメントに書かれていた。 > ```javascript > exports.onServiceWorkerUpdateFound = () => { > const answer = window.confirm( > `This application has been updated. ` + > `Reload to display the latest version?` > ) > > if (answer === true) { > window.location.reload() > } > } > ``` > > https://www.gatsbyjs.org/docs/add-offline-support-with-a-service-worker/ が、これだとページを初めて開いたときにもこの表示が出てしまうので、`onServiceWorkerUpdateReady`というのを追加しようというPull Requestがある。 gatsbyjs/gatsby#10432 これがマージされたらこっちに切り替えよう。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I haven't tested it myself but it seems to be solid.
I'll let @pieh to do a final review
@@ -34,8 +35,10 @@ | |||
}, | |||
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-offline", | |||
"scripts": { | |||
"build": "babel src --out-dir . --ignore **/__tests__", | |||
"build": "npm run build:src && npm run build:sw-append", | |||
"build:src": "babel src --out-dir . --ignore **/__tests__", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to ignore sw-append.js
here? for builds it probably doesn't matter - it will be overwritten by cpx in next step, but while watching, babel will try to compile it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yep, that's a good point - need to fix that
Co-Authored-By: davidbailey00 <4248177+davidbailey00@users.noreply.github.com>
Just need to bump |
Has anyone experieced this "missing recourses" error on a gatsby site without PWA or using |
@sgnl Please could you open an issue describing this behaviour if you're still having it? Thanks 🙂 Just a heads up, sometimes it can be caused by adblockers so if you're using one, try disabling it and see if you get the same issue. |
Fixes #10036