Reputation: 11728
I have a question that is related to this answer, $.getScript(filename)
Are dynamically loaded files cached by the browser?
If not, how can I force them to be?
Upvotes: 4
Views: 974
Reputation: 1038720
It seems that they are not. Proposed workaround is to redefine the function:
$.getScript = function(url, callback, cache) {
$.ajax({
type: "GET",
url: url,
success: callback,
dataType: "script",
cache: cache
});
};
which could be used like this:
$.getScript('/foo.js', function() { }, true);
Upvotes: 4