Are dynamically loaded files cached by the browser?

I have a question related to this answer, $. getScript (file name)

Are dynamic download files cached by the browser?

If not, how can I make them be?

+3
source share
1 answer

It seems that they are not . The proposed workaround is to override the function:

$.getScript = function(url, callback, cache) {
    $.ajax({
        type: "GET",
        url: url,
        success: callback,
        dataType: "script",
        cache: cache
    });
};

which can be used as follows:

$.getScript('/foo.js', function() { }, true);
+3
source

Source: https://habr.com/ru/post/1787159/


All Articles