This article describes the solution to the problem of AngularJS always cache data in IE. Share it for your reference, as follows:
question:
By making a request (GET) using AngularJS to get server data and then binding it to the page, you will find that the original data result is always displayed in IE. At this time, we will know that IE has made cache.
Solution:
We can set it not to cache through $httpProvider in AngularJS configuration. The details are as follows:
ngApp.config(function ($httpProvider) { // Initialize get if not there if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } // Enables Request.IsAjaxRequest() in ASP.NET MVC $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest'; //Disable IE cache for ajax $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';});I hope this article will be helpful to everyone's AngularJS programming.