I just want to clear the browser cache using angularjs, every time i login to my application and browser should load new files.
-
2through javascript?Sajeetharan– Sajeetharan2016-11-22 13:22:31 +00:00Commented Nov 22, 2016 at 13:22
-
2maybe have a look at a previous post stackoverflow.com/questions/31850824/…Marius Brits– Marius Brits2016-11-22 13:22:34 +00:00Commented Nov 22, 2016 at 13:22
-
javascript or angularjs whatever the best way.Rinkal Garg– Rinkal Garg2016-11-22 13:24:02 +00:00Commented Nov 22, 2016 at 13:24
2 Answers
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!
1 Comment
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.