Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deployed react web app requires hard refresh

Bootstrapped with create-react-app (v1.0.13). Whenever I update the source & redeploy users need to hard refresh to get the new content. I've included non-cache header in index.html:

<meta http-equiv="Cache-Control" content="no-store" />

& turned off provided service workers. Also change the .js filename (and reference in index.html) in build folder before deploying.

like image 552
Brad Woods Avatar asked Sep 06 '17 16:09

Brad Woods


1 Answers

I was able to remove caching by doing the following:

  • adding the following to in index.html <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" />
  • inserting the following to the js import { unregister } from './registerServiceWorker'; unregister()
  • changing cloudflare caching expiration to 'respect existing headers' at https://www.cloudflare.com/a/caching/

It is unclear which of these (or all of these) are actually required but it's a start.

like image 84
Brad Woods Avatar answered Oct 13 '22 19:10

Brad Woods