How can I force clients to refresh JavaScript files?

后端 未结 26 2277
旧时难觅i
旧时难觅i 2020-11-22 03:40

We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slo

26条回答
  •  攒了一身酷
    2020-11-22 04:26

    The jQuery function getScript can also be used to ensure that a js file is indeed loaded every time the page is loaded.

    This is how I did it:

    $(document).ready(function(){
        $.getScript("../data/playlist.js", function(data, textStatus, jqxhr){
             startProgram();
        });
    });
    

    Check the function at http://api.jquery.com/jQuery.getScript/

    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.

提交回复
热议问题