Service Worker weird caching
See original GitHub issueIs this a bug report?
Yes
Did you try recovering your dependencies?
Yes
Which terms did you search for in User Guide?
https://github.com/facebook/create-react-app/issues/2398
Environment
Environment Info:
System: OS: macOS High Sierra 10.13.6 CPU: x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Binaries: Node: 9.10.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 5.6.0 - /usr/local/bin/npm Browsers: Chrome: 69.0.3497.100 Firefox: 62.0.3 Safari: 12.0 npmPackages: react: ^16.5.2 => 16.5.2 react-dom: ^16.5.2 => 16.5.2 react-scripts: 2.0.4 => 2.0.4 npmGlobalPackages: create-react-app: 2.0.3
Steps to Reproduce
(Write your steps here:)
- Clone https://github.com/gabrielmicko/react-create-app-pwa. It is almost a clean app of react-create-app.
- Install dependencies.
yarn install
. Create a build.yarn run build
. - Run
serve -s build
(if you don’t have serveyarn global add serve
), ornode server.js
. - Open localhost:5000. You should see service worker precaching files.
- Do some change in the
App.js
and runyarn run build
again. - Refresh the page and check your console. You should see the new files. It will log an “Update happened” message.
- Refresh the page to see the updates.
- Can’t see the changes I made.
Expected Behavior
After refreshing the page at point 7. I should see my changes.
Actual Behavior
I see the old version of my app.
(Write what happened. Please add screenshots!)
Reproducible Demo
Issue Analytics
- State:
- Created 5 years ago
- Reactions:25
- Comments:71 (14 by maintainers)
Top Results From Across the Web
Chrome service worker not intercepting cached requests
The behavior described above is caused by the in-memory cache in Chrome's rendering engine Blink. All requests served from the in-memory ...
Read more >Understanding Service Workers and Caching Strategies
If any single file is not cached, then the service worker is not installed. So, it is important to make sure that there...
Read more >Service worker caching and HTTP caching - web.dev
A service worker intercepts network-type HTTP requests and uses a caching strategy to determine what resources should be returned to the ...
Read more >Using Service Workers - Web APIs | MDN
A service worker functions like a proxy server, allowing you to modify requests and responses replacing them with items from its own cache....
Read more >Strategies for Service Worker Caching for Progressive Web ...
Service worker caching strategies before and after deployment for react apps. ... Do not cache certain pages to avoid weird behavior.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to close all tabs or fully close the browser to see the changes reflected. A page reload will not reflect the changes.
@sky93 With CRA v3 you can post a message
SKIP_WAITING
to the service worker to trigger skip waiting.But usualy you want ot ask user before doing reload. I used wrapping service worker registration into the React context:
The only additional change required in the
serviceWorker.js
file of CRA if you want to register service worker from the React application. You need to get rid of thewindow.onload
event waiting in theregister
function :