简体   繁体   中英

jquery doesnt cache javascripts which loading from html

Im having a really difficult time here. Actually when I load a HTML file with Jquery which contains Javascript files (included in my html), jquery adds timestamp to the file source to prevent it from being cached whereas this timestamp is not available in our source. What I want to do is remove the timestamp from javascripts to allow them to get cached. It would be great if someone could help me with this.

I have personally used code like the following to set HTML content obtained from an AJAX request, without adding the caching busting query string to any scripts in the HTML.

// Get ajaxHTML from an AJAX request.
var ajaxCache = $.ajaxSetup().cache;
$.ajaxSetup({cache: true});
$('.someelement').html(ajaxHTML);
$.ajaxSetup({cache: ajaxCache});

Basically it changes the default settings temporarily before calling .html , then sets it back afterwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM