I have a bash script to stage my app that looks like this: version=$(cat $DIR/releases.json | jq '.version') version="${version%\"}" version="${version#\"}"
build=$(node -e 'console.log(Date.now())') jq '.build = '$build releases.json > tmp.$$.json && mv tmp.$$.json releases.json sed -ie "s/MyApp.js/MyApp.js?{build_number}/g" bin/js-release/index.html sed -ie "s/{build_number}/$build/g" bin/js-release/index.html sed -ie "s/{version_number}/$version/g" bin/js-release/index.html releases.json has the version and the build number is updated by this script. The template html has this: <meta name="build" content="{build_number}"> <meta name="version" content="{version_number}"> <link rel="stylesheet" type="text/css" href="${application}.css?{build_number}"> The HTML file on the server has a very short TTL. The rest of the files have a much longer TTL. The build script busts the cache when it’s deployed. Change “MyApp” to the name of your app. HTH, Harbs > On Mar 9, 2023, at 10:43 PM, Hugo Ferreira <hferreira...@gmail.com> wrote: > > Hi, > > I'm releasing now updates more often and sometimes (many times), the > browser cache my App.js > In a quick google search I found a solution (more a workaround) => > https://stackoverflow.com/questions/1011605/clear-the-cache-in-javascript > When I build - release with VS Code, it inject this line on my html > file:<script type="text/javascript" src="./App.js"></script> > So, I don't have control over it. > > What I would like to do is something like have a version flag of my App in > the asconfig.json and when I build - relase the compiler inject something > like:<script type="text/javascript" src="./App.js?v=1"></script> > <script type="text/javascript" src="./App.js?v=2"></script> > ... > > This is possible today ? > > Regards, > Hugo.