-
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
[gatsby-plugin-offline]: Wrong default caching strategy for page-data #24930
Comments
* fix(sw): use NetworkFirst strategy for page-data Fixes #24930 * fix(sw): NetworkFirst strategy for app-data.json * fix(sw): StaleWhileRevalidate for page-data and app-data
This issue is not fixed despite the commit and merge, because only |
I clicked on a link to https://www.gatsbyjs.org/ today, which showed a blank (black) page. So there you have it. This bug even shows up on your own web site. |
This is still an issue for us. |
@LiamDotPro I THINK I experienced it as well in my projects. As my hoster has wonderful caching, I decided to just remove the whole plugin. This popup with "there is new content, reload the page" was more confusing to users als helping. Not saying that I fixed the issue, but removing the plugin helped a lot to avoid dead ends on recurring visitors! |
* fix(sw): use NetworkFirst strategy for page-data Fixes gatsbyjs#24930 * fix(sw): NetworkFirst strategy for app-data.json * fix(sw): StaleWhileRevalidate for page-data and app-data
Description
I had some weird, apparently random rendering issues after I renamed some fields in a GraphQL page query. On the initial load, UI components were displayed with empty texts, whenever they were sourced from updated page query data. After a reload, the page appeared correctly.
I do believe it's a service worker caching issue and I think this piece of configuration is the source of the problem:
gatsby/packages/gatsby-plugin-offline/src/gatsby-node.js
Lines 142 to 144 in f14c99b
I think it should be
NetworkFirst
sinceStaleWhileRevalidate
creates the possibility that changed code that expects an updated page query structure can potentially run on temporarily served, outdatedpage-data.json
The official plugin documentation states, that it is
NetworkFirst
by default, but in code, it is not. I will send a PR if this is approved.Steps to reproduce
Make breaking structural changes in a GraphQL page query like renaming frontmatter fields in markdown and update the page query (after the site has been deployed and cached before). Make use of the updated query result in UI components of the page/template.
Expected result
Texts of UI components that are sourced from the updated query structure should be displayed since the initial load.
Actual result
Texts of UI components that are sourced from the updated query structure were empty on the initial load. They were displayed on subsequent loads.
Environment
gatsby info --clipboard
yarn list | grep gatsby | grep -v deduped
The text was updated successfully, but these errors were encountered: