Reputation: 72
I just want to clear the browser cache using angularjs, every time i login to my application and browser should load new files.
Upvotes: 1
Views: 7581
Reputation: 403
I recommand you to use grunt-cache-breaker is a simple cache-breaker, appends a timestamp or md5 hash to any url.
This plugin requires Grunt.
Upvotes: 1
Reputation: 10714
You don't really do this using Angular, per se. There are a few ways you can cause your browser cache to invalidate/force your browser to request a fresh resource. A common way of doing this is cache busting your application assets. For example, whenever your JS changes, you have a task running (Grunt/Gulp/Webpack are good examples of this) that will rename your file to something new (usually by appending a hash or date to the end of the filename) so that when your browser requests your page, it will see a brand new filename and request a copy of it.
An example of something that can do this is gulp-rev: https://github.com/sindresorhus/gulp-rev and here is a tutorial: https://stefanimhoff.de/2014/gulp-tutorial-13-revisioning/
Hopefully this helps!
Upvotes: 8