Marc Rasmussen Marc Rasmussen - 1 year ago 184
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download