Are Dynamically Loaded Files Cached by the Browser?
I have a question that is related to this answer, $.getScript(开发者_JS百科filename)
Are dynamically loaded files cached by the browser?
If not, how can I force them to be?
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);
精彩评论