0

I'm using React and Webpack to create a completely front-end application. I just made some changes to my build. Now my concern is that my users won't get to use the latest bundle but the cached bundle by their browsers. How can I get them to load the latest bundle?

Stanley Nguyen
  • 442
  • 3
  • 18

2 Answers2

3

It is not recommended to add a code for loading assets forcefully in client browser as this will result in the slow rendering of application.

The task you want to achieve can be done by adding a new query parameter version on your script tag and change that version whenever you want to load new code.

something like

<script type="text/javascript" src="myfile.js?REVISION"></script>
Gaurav joshi
  • 1,743
  • 1
  • 14
  • 28
0

I found a trick. Try adding a query parameter in the script url.

For example: http://example.com/scripts/bundle.js?something=something

I think that prevents browsers from caching the file.

vothaison
  • 1,646
  • 15
  • 15