Update: AppCache was deprecated in the summer of 2015, so below is not the best solution. A new recommendation is to use Service Workers instead. However, service workers are still experimental with fragmentary (readable: maybe not) support in IE and Safari.
Alternatively, many build tools now seamlessly integrate file-based caching and processing methods with "versions" to solve the OP issue. WebPack may be the current leader in this space.
This might be a good use case for HTML5 AppCache.
You will probably want to automate some of these steps in your deployment script, but here is some code that might come in handy to get you started.
First create the appcache manifest file. It will also allow you to cache resources in the client browser until you explicitly change the date of the application manifest file.
/app.appcache:
CACHE MANIFEST
In app.appcache, the comment on line #v20150327.114142 is how we tell the browser that the manifest has changed and the resources must be reloaded. It can be anything if the file differs from the browser of the previous version. When you deploy new code in your application, this line must be changed. You can also use the assembly identifier.
Secondly, on any pages that you want to use appcache, change the title tag as such:
<html manifest="/app.appcache"></html>
Finally, you need to add Javascript to check the appcache for any changes, and if so, do something about it. Here's the angular module . For this answer, a vanilla example:
appcache.js:
window.applicationCache.addEventListener('updateready', function(e) { if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { // Browser downloaded a new app cache. // Swap it in and reload the page to get the latest hotness. window.applicationCache.swapCache(); if (confirm('A new version of the application is available. Would you like to load it?')) { window.location.reload(); } } else { // Manifest didn't changed. Don't do anything. } }, false);
Alternatively, if AppCache does not work for your situation, a more ghetto solution would be to create a simple API endpoint that returns the current assembly ID or the date of the last deployment. Your Angular application sometimes falls into this endpoint and compares the result with the internal version, and if it differs, it restarts itself.
Or you might think about reloading the script ( example ), but being very useful in development, I'm not sure how good the idea is to use live / in-place reloading of assets in production.