Marc Rasmussen Marc Rasmussen - 3 months ago 51
AngularJS Question

AngularJs force browser to clear cache


application is constantly changing these days because our team runs rapid updates right now.

Because of cache our clients does not always have the newest version of our code.

So is there a way in
to force the browser to clear cache?


You can use a very simple solution that consist in append a hash to your scripts files. Each time your App is deployed you serve your files with a different hash automatically via a gulp/grunt task. As an example you can use gulp-rev. I use this technique in all my projects and works just fine, this automatized in your build/deploy process can be a solution for all your projects.

Yeoman generator for AngularJS generator-gulp-angular (this was my generator of choice) use this solution to ensure that the browser load the new optimazed file and not the old one in cache. Please create a demo project and play with it and you will see it in action.