I have an embed webpart in sharepoint that showcases part of our available content, it’s an html file that calls a script.js generated by an excel spreadsheet. The list of content changes often enough that multiple updates are pushed every week, often once a day.
Currently, it reads the .js correctly, but, if the file changes, it only reads the file again on a force reload.
I have tried adding the following code to my HTML:
<meta http-equiv="Cache-Control" content="no-cache,no-store, must-revalidate"/>
But it didn’t change my situation.
Is there any way I can make it update without the user force reloading the page?
Ideally, only the HTML file would be edited, because the .js is generated automatically.
2
Answers
Add a random number to the URL if you can.
Depending on how you generate the url in the first place the syntax may vary but something along the lines of
So make a new script that you always load with this code, referencing to your real script (my.js) and load this script instead from your html file and you should be fine.
you can add a time stamp to the end of the JavaScript file URL to ensure that the browser always loads the latest version of the file.