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

[1.0] Client caching issues #1193

Closed
m4rrc0 opened this issue Jun 17, 2017 · 12 comments
Closed

[1.0] Client caching issues #1193

m4rrc0 opened this issue Jun 17, 2017 · 12 comments

Comments

@m4rrc0
Copy link
Contributor

m4rrc0 commented Jun 17, 2017

Hey, congrats for the beta release! Things are moving fast. That's awesome.

Since I started using the offline and manifest plugins my site shows old data and sometimes errors... I messed a lot with it so I can't really trace back to a step by step reproducible problem but what I know is whatever the problem is, it gets resolved when I unregister service workers. Shouldn't this be done every time the user is online to make sure they get the latest data?

@KyleAMathews
Copy link
Contributor

Yes :-)

I've been noodling over this the past week or so and I have a number of tweaks I'm going to be making to core & the offline plugin (as it's not just with SW this problem shows up though it's much more likely to show up with a SW).

Will report back early next week with a PR.

@KyleAMathews
Copy link
Contributor

Did some work on this #1217

If a user w/ sw navigates to a page it doesn't know it immediately reloads. Also when a new service worker is installed the page is reloaded. Makes for a bit of a "hiccup" but it's not too bad (loading from the sw is fast). We'll roll with this for a while and see how we like it.

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Jun 21, 2017

Thanks Kyle, I'll check the result on my site today.

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Jun 21, 2017

Okayyy. Feedback from my side: I had to manually refresh the page. So when landing on homepage then navigating to another page (with new content from last build) the site gave an error in the console. When I refresh manually, everything is fine.
I guess it may be related to the way I get my data on build (not through a plugin but a custom script) and/or the fact that I had the old sw...
I will report back in the coming days when my data change again.
Thanks again for the work

@KyleAMathews
Copy link
Contributor

Yeah, this stuff is slow to test because you have to build to get the new sw then do another build to test the upgrade :-( took a while to build because of that.

I've been testing it via gatsbyjs.org upgrades and it seems pretty solid.

@KyleAMathews
Copy link
Contributor

Thanks for testing! Please report back any problems or suggestions for improvements.

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Jun 24, 2017

Hey. Just a small update confirming what I said above.

  1. Manual refresh is needed to get the new content. When checking the Gatsby website today I had to manually refresh to see the plugins page (I didn't think about looking in my console but I guess there was some red printing there)
  2. It seems that if new data is added with a custom script (not a plugin and not using Gatsby's API), it never shows even on manual refresh.
    -> My build: node fetchMyDataAndWriteInAJsonFile && gatsby build. I have a cron task to rebuild everyday on netlify. When doing so, data never shows. If I fetch locally then push to Github, it works alright though (except for 1.).

Obviously 2. is not a "real issue". It's on me if I don't use Gatsby's API.

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Jun 26, 2017

Here is the console error when visiting Gatsby website today:
Failed to load resource: the server responded with a status of 404 ()
For files:
page-component---src-pages-docs-index-js-fe4698ea9f81f1bf0ef8.js &
app-b75066f8b2a017dd8b53.js
Refreshing solves it. Hopefully you know what to do with that @KyleAMathews ...?

@KyleAMathews
Copy link
Contributor

@MarcCoet did the page refresh once the new service worker comes in?

@KyleAMathews
Copy link
Contributor

The site is supposed to load from the service worker and have all the site resources cached there and then once a new SW comes in, it should reload immediately.

The only way I can happening what you saw is if the SW hadn't cached a file e.g. like there, the home page component, which is possible as right now since it's not precaching all page components.

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Aug 14, 2017

Hey @KyleAMathews. Did I answer you somewhere else? I just found back this issue and noticed you were still hanging there. Crazy time for me, sorry.
For the record I still get a bunch of 404 when I visit gatsby website. The new service worker is coming ok but there's no reload.
I only tested in Chrome (2 different systems though).

@flipactual
Copy link
Contributor

I am also having this issue – load a new url with old sw in place, sent to 404, have to reload, re-navigate to original url

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

3 participants