Skip to content Skip to sidebar Skip to footer

Force Clients To Reload My Bundle.js

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 b

Solution 1:

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

<scripttype="text/javascript"src="myfile.js?REVISION"></script>

Solution 2:

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.

Post a Comment for "Force Clients To Reload My Bundle.js"