How can JS/CSS cache busting be implemented for SharePoint Online in a master page? Other methods detailed on StackExchange do not work as SPO developers do not have access to the _layouts folder to store their custom JS/CSS files. I currently store my custom JS/CSS files in a read-only document library that everyone has access to. Some have posted about using a CDN, but there must be something easier.

Of course this can be manually accomplished by appending a "?v=[randomstring]" to your script filename but that isn't a best practice.

Ideally, I would like to utilize the OOTB cache management that SPO uses for its scripts where it adds a version number parameter.


1 Answer 1


That OOTB cache management is done Server-side..

and with SPO.. Microsoft owns and maintains the Server

So you have to fix it Client-Side, like UserCustomActions (because they execute way before your Masterpage scripts) loading your files dynamically

first Google hit: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml

  • So really it sounds like I should avoid the masterpage completely for loading scripts, use the method from the link you provided, and append a random string to my scripts to always bust the cache. Do you agree?
    – Jiffy
    Mar 8, 2017 at 18:48
  • Not messing with the MasterPage has been preferred practice since UserCustomActions were released in SP2010. This is from my own learnings a year ago: sharepoint.stackexchange.com/questions/178337/… Mar 8, 2017 at 18:54
  • This Chrome Extension helps with UserCustomActions: chrome.google.com/webstore/detail/sp-editor/… Mar 8, 2017 at 18:56
  • Good extension - thanks. It may be better to use a custom client side solution (as you suggested earlier) in this case to bust the cache. I tried adding some JS code directly in the extension - and it works - but it breaks the removal of that specific scriptlink.
    – Jiffy
    Mar 8, 2017 at 20:27
  • I think the extension can only set the ScriptLink (to any https location you want), you need other code to set ScriptSrc Mar 8, 2017 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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