-
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 requires two reloads to provide an offline experience #39041
Comments
@sauraeveth Thanks for reporting. The issue seems to be that the service worker isn’t caching the initial page load properly, causing a blank page on subsequent loads after a clean build. I’ll investigate and work on a solution to ensure the index page is correctly cached on first load. I’ll update with progress. |
…first reload" --body "This PR addresses issue gatsbyjs#39041 by ensuring that gatsby-plugin-offline provides an offline experience on the first reload without requiring a second reload. Signed-off-by: Emmett Hoolahan <emmetthoolahan@gmail.com>
Hi @emmron, Thanks for the quick response. Hopefully someone from the gatsby team can take a look and let us know about the correctness of the solution |
…first reload" --body "This PR addresses issue gatsbyjs#39041 by ensuring that gatsby-plugin-offline provides an offline experience on the first reload without requiring a second reload. Signed-off-by: Emmett Hoolahan <emmetthoolahan@gmail.com>
Preliminary Checks
Description
I have used gatsby-plugin-offline along with gatsby-plugin-manifest as described in the documentation. After doing a clean build on a new browser tab (without any previous caching) the first load works successfully and caches the main files such as framework, app, etc. However, it fails to cache the actual index page file which starts with component-src-.
Now if I kill my server or shut my network or I just do a clean build again, the component-src- file would have changed and since the service worker exists because of the first load, it tries to respond to this request. However it can't because it was never cached and hence a blank page is shown.
This issue is critical because there might be cases where a clean build is required if we ever get into some weird caching bug and that has the potential to hamper the experience of all those users that just came once
Please refer the video that showcases the above
Screen.Recording.2024-07-13.153833.mp4
Reproduction Link
https://github.com/sauravseth/minimal-repro-for-offline-plugin-issue
Steps to Reproduce
git clone https://github.com/sauravseth/minimal-repro-for-offline-plugin-issue.git
gatsby serve
commandExpected Result
The 2nd reload after installation of the service worker should've worked because the same page without any changes was loaded once and it worked without any errors
Actual Result
The 2nd reload results in a blank page which can be a common scenario if a clean build is done and users have only visited the site once
Environment
Config Flags
No response
The text was updated successfully, but these errors were encountered: