andrewmclagan/react-env

Cache Busting

Closed this issue · 3 comments

Hello this is more of a question on how/if you implement cache-busting. I am currently using react-env in a production application and we are often updating ENV vars. However, the file is cached for users and for us devs during testing. Just wondering if you ran into this as well.

Very useful library, really appreciate this work! 👍

Interesting, have never encountered cache issues with the __ENV.js file. Totally possible .

You could append the next.js build number e.g.

script="__ENV.js?87373838837282838"

Thanks for your prompt reply here!

We ended up going with a similar solution. A script that adds script="__ENV.js?<hash>" where the hash is of all REACT_APP variables in the environment. We use this in our entrypoint.sh in our Dockerfile so that we can bust the cache without rebuilding the app.

Great news. I will make a note in the readme