Make $.getscript("") Not Add Numbers At The End Of The Request
I am using $.getScript() to get a script from somewhere. function fetch(url){ window.setInterval(function (){ $.getScript(url); },50000) } fetch('http://example.com/script.js');
Solution 1:
It's because jQuery sets caching to false
(by default) when you use $.getScript()
.
From the jQuery documentation:
By default, $.getScript() sets the cache setting to false. This appends a timestamped query parameter to the request URL to ensure that the browser downloads the script each time it is requested.
To disable caching, add the following before the $.getScript
call:
$.ajaxSetup({
cache: true
});
Solution 2:
$.getScript()
tries to bypass the cache to always download the latest files. The numbers are a timestamp.
To disable this you need to set this propery:
$.ajaxSetup({
cache: true
});
Post a Comment for "Make $.getscript("") Not Add Numbers At The End Of The Request"