gatsby-plugin-offline requires two reloads to provide an offline experience #39041
Open
2 tasks done
Labels
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
type: bug
An issue or pull request relating to a bug in Gatsby
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: