Production build only shown after hard refresh

Posted November 15, 2020 4k views

Hi there, I have an Node/React app deployed to App Platform. I am facing a problem when I deploy any changes, I am not served the new production build files. I am served files but nothing gets rendered on the page. If I open the chrome debugger, and right click on refresh to get empty cache and hard reload, my app begins rendering again. I’d guess I am being served old production assets, and they’re no longer valid? Not sure why. Anyone had this problem?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

on further inspection it does seem the main.[HASH].js file is not being updated. Hard reloading via clearing cache does load the correct hashed js file. Is there a way to tell App Platform to clear the cache on deploy to the client?

For anyone who finds this, I believe I fixed it with the use of react-clear-cache to conditionally check for latest production builds. I also enabled the service worker in create react app via serviceWorker.register() in the top level index.js

After even further investigation, the react-clear-cache did not do the trick. Still looking for a solution to this.