When loading a javascript file I can force the browser to not use the cache by adding a version when loading the file e.g.
<script src="~/angular/myapp/app.js?version=123"></script>
From inside my angular app I am doing this:
$routeProvider.when("/", {
controller: "userController",
controllerAs: "vm",
templateUrl: "Path/to/Template/Index.html"
});
How can I make sure that any changes I made to the Index.html won't be cached? Or this isn't an issue for some reason?
angular 1.x
You could do the same for your
Index.htmlfile. Simply append a "cache buster" query string as you did to your js file. There are a few techniques to do this, but a simpleDate.now()timestamp should demonstrate the goal ...If your app grows in complexity and you wish to prevent caching of templates altogether, you can achieve this with some middleware...
The above example assumes a directory of
viewsfor your templates.Finally, as a comment pointed out, if you are simply wishing to prevent caching for local development, you can toggle settings to disable cached resources through your browsers dev tools.