When loading html content through $.load, and the html content contains <script>
tags referencing javascript files, the linked Javascript files are appended with a cache busting parameter, which prevents the file from being cached by the browser.
So, instead of requesting something like <script src="/js/foo.js">
, it requests <script src="/js/foo.js?_=123123">
, causing the script to be loaded every time.
Is there a way to disable this behavior?
You can try to force caching
$.ajax({
url: "/yourpage",
cache: true,
dataType: "html",
success: function(data) {
$("#content").html(data);
}
});
.
$.ajaxSetup({
cache: true // Enable cache as jQuery won't let the script be cached by default
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With