django - Angular: Add to each request a random number in order to disable caching for IE -


ie heavily caching xhr requests. overcome problem users suggested add random number url. example here

whereas work, i'm looking way add random number globally / disable ie caching globally, , caching has disabled resource xhr calls. i'm guessing achieve goal using 1 of following approaches. i'm not sure have do..

a) using $httpprovider.defaults.transformrequest

b) using request/response promise chaining have been added in v 1.1.4

this old issue ie. not sure how muck angular's $httpprovider (or want to), here function adds random value url, whether or not uses query string:

function nocacheurl(url) {     var urlparser = document.createelement('a');     urlparser.href = url;     var q = "nc" + math.random() + "=1";     q = urlparser.search ? urlparser.search + "&" + q : "?" + q;     return urlparser.protocol + "//" + urlparser.host + urlparser.pathname + urlparser.hash + q; } 

note name of added query param random, not value, making less collide existing name/value pairs. example: &nc0.8578296909108758=1

http://jsfiddle.net/lgjle/


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -