-
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
fix(sw): use NetworkFirst strategy for page-data #24940
Conversation
I just found out that gatsby/packages/gatsby-plugin-offline/src/gatsby-node.js Lines 146 to 150 in 88d5eeb
|
Relevant history around this: #19342 Bottom line, the change of handler is non-trivial and probably really depends on user preference. We have to pick a default that makes sense for most. The upside to Also, note that this setting can be changed by a user. The docs could need a little updating around this. If we really wanted to change the handler setting we would first need to properly investigate the impact across the board. For now we would like to keep the handler as is. However, the addition of app-data is good. Could you please update the PR to add |
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.
(Please revert the change to handler
, but do add the app-data.json
section, with its handler
also set to StaleWhileRevalidate
)
Hi @pvdz I set I looked into #19342 and of course @KyleAMathews describes the possible implications there and those are exactly the kinds of problems I ran into. Updated Markdown data was missing, and uncaught unexpected TypeErrors were thrown from intermixing outdated with updated code. I got those same errors reported from several internal users in a field test scenario (only with as much information as "text missing" and "white page") who all have visited the site before. I also observed those issues on my mobile devices where I did not clear up application caches. This kind of stuff is very hard to reproduce (it's kind of possible like I described in #24930) and very detrimental to UX. Since I use I can hardly imagine that anybody wants their users to see missing content or white pages on a regular basis after code updates, so I think this should definitely be reconsidered, since it kind of breaks things out-of-the-box. At least the docs should be updated and mention those kinds of problems and explain the implication of caching strategies in more detail. |
Quoting @pvdz:
That can't be the right default and in this case, it cannot depend on user preference if it is causing caching bugs in the real world. The quoted issue you referenced above changed the handler from originally
Issue #19342 basically kills any kind of caching reliability for web sites in production, so this cannot be the right default. Gatsby feels so fast because of its aggressive caching and preloading, which is only employable if you can expect it to be reliable, but this PR makes Gatsby's caching unreliable. |
A PR on that is welcome (this is for the learning team to process). I agree this could be exposed better and described more clearly. I also agree with the inconsistency pointed out by @21c-HK on caching json files. This may be the case of outdated docs or it may be the case of incorrect implementation. I'm not sure tbh.
I appreciate those thoughts. I do understand your point and am not saying we're not going to change it. If and when we do, we want to make sure all implications are considered. A double blocking round trip could have severe impact on site perf. If we can prevent that by other means then that might have a preference. But other means have a cost too, so it's an equation we have to solve. My suggestion on this would be to open a discussion issue and hash out the pro's, cons, and alternative solutions. Answer the question: Why should AND why should this not be changed? Then weigh the cost of each option. I'm going to merge this PR. Thank you for making the changes and the PR in the first place 💜 |
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.
💜
* 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
I am pretty sure that the current implementation (even after the merge) is incorrect with
I am not arguing that there might not be a better caching strategy or implementation, but
What is confusing to me is that this was not done for that problematic PR, which is causing bugs that went unnoticed until now. In any case, the cost of these caching bugs is so high that they outway any possible performance benefit, IMO. @KyleAMathews had doubts about that PR back then because he anticipated these problems:
I hope @KyleAMathews can weigh in because he probably knows what would be the best solution. |
Issue #24930 is not fixed despite the commit and merge, because only |
* 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
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. |
* 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
Fixes #24930