Adding a script to the page dynamically with jQuery never uses the cached file

前端 未结 3 822
傲寒
傲寒 2020-12-15 23:07

I am using jQuery to dynamically add a script to my page and it works, but jQuery appends \"_=TIMESTAMP\" to the URL causing the browser to never use the cache. With the fo

3条回答
  •  甜味超标
    2020-12-15 23:53

    Here is something that works for me

    // Backup the jquery ajax cache setting
    var jQueryAjaxSettingsCache = jQuery.ajaxSettings.cache;
    
    // Disable the ?_=TIMESTAMP addition
    jQuery.ajaxSettings.cache = true;
    
    // Do the cached script inserting ...
    $("head").append('
    
                                     
                  
提交回复
热议问题