从IE发送的所有ajax调用都被Angular缓存,我304 response为随后的所有调用获取a 。尽管请求是相同的,但在我的情况下响应将是不同的。我想禁用此缓存。我尝试将cache attribute$ http.get 添加到它,但仍然没有帮助。如何解决此问题?
304 response
cache attribute
我没有为每个GET请求禁用缓存,而是在$ httpProvider中全局禁用了它:
myModule.config(['$httpProvider', function($httpProvider) { //initialize get if not there if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } // Answer edited to include suggestions from comments // because previous version of code introduced browser-related errors //disable IE ajax request caching $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; // extra $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; $httpProvider.defaults.headers.get['Pragma'] = 'no-cache'; }]);