All the ajax calls that are sent from the IE are cached by Angular and I get a 304 response
for all the subsequent calls . Though the request is the same, the response is not gonna be the same in my case. I wanna disable this cache. I tried adding the cache attribute
to $http.get but still it didnt help. How can this issue be resolved?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can either append a unique querystring (I believe this is what jQuery does with the cache: false option) to the request.
A perhaps better solution is if you have access to the server, then you can make sure that necessary headers are set to prevent caching. If you're using
ASP.NET MVC
this answer might help.This only line helped me (Angular 1.4.8):
UPD: The problem is IE11 does aggressive caching. When I was looking into Fiddler I noticed that in F12 mode requests are sending "Pragma=no-cache" and endpoint is requested every time I visit a page. But in normal mode endpoint was requested only once at the first time when I visited the page.
Solution above will work (make the url unique by adding in the querystring a new param) but I prefer the solution propose [here]: Better Way to Prevent IE Cache in AngularJS?, which handle this at server level as it's not specific to IE. I mean, if that resource should not be cached, do it on the server (this as nothing to do with the browser used; it's intrisic to the resource).
For example in java with JAX-RS do it programatically for JAX-RS v1 or declativly for JAX-RS v2.
I'm sure anyone will figure out how to do it
I get it resolved appending datetime as an random number:
Instead of disabling caching for each single GET-request, I disable it globally in the $httpProvider:
To avoid caching, one option is to give different URL for the same resource or data. To generate different URL, you can add a random query string to the end of the URL. This technique works for JQuery, Angular or other type ajax requests.