Last Updated: February 25, 2016
·
2.922K
· kennu

Cache-bust Require.js scripts when developing locally

Developing JavaScript (or CoffeeScript) with Require.js can be very frustrating because the browser tends to cache previous versions of scripts until you clear the cache.

However, you can bust the cache by adding this configuration option to Require.js:

requirejs.config
  urlArgs: new Date().getTime().toString()

That will cause all files to be loaded with a timestamped query string, thus bypassing the browser cache.