SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run some custom scripts on one of my pages. No problem, just put in the script tag...

<script type="text/javascript" src="scripts/init.js"></script>

and I add my init.js to SitePages/scripts/ and then my script runs fine the first time around. Only problem is, I can make changes to the script and save them, but the website will still use the original init.js, and it is impossible to get the new script to run under the same name, as the original init.js is for whatever reason still stored on the sharepoint site. I know this because the first init.js had an alert('Init ran!');, but then when I made changes I changed the alert to alert('Updated init ran!') but when I save the file it still displays an alert with the first "Init ran!", so it's obviously not updating. Why does this happen and how can I fix it?

share|improve this question
up vote 4 down vote accepted

This is simply browser caching, and it is pretty predominant in SPO.

Some things to try:

  • Hard refresh your page (Shift + F5)
  • Use a private browser tab
  • Update your js file reference with ?rev=1 to force a download of the file. Increment this number every time you make a change to your init.js file.
share|improve this answer

While developing, set your browser to Disabled caching in F12-Developer Tools

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.