I’ve built and deployed a React app using Create React App to Netlify. It works great!
I then added my site to my iPhone’s home screen with the “Add to Home Screen” button, which sort of turns it into a PWA. However, I did disable my React app’s service worker.
I’m having issues with caching and reloading the app.
If I push new code to Netlify and it re-deploys, I can see it if I visit my site in the browser, but the homescreen app is stale. It doesn’t get an update, even if I close the “app” and reopen it.
I’ve googled this and folks have mentioned adding some sort of task that polls the server looking for a new version of my app, and then prompting the user to refresh the app which would trigger a hard reload, using something like
window.location.reload(true). I wanted to ask here what’s the “best practice” here? It seems like there’s a lot of friction to get this working right. Would it be possible to solve by changing the cache headers Netlify uses for my app’s
index.html file? (All the assets are fingerprinted so I know HTTP caching is not the issue there.)
If I do have to implement this myself, what’s a common way to “check the server” for a new version of my app?
Would love to hear how folks are solving this!