Jquery disable cache for external scripts loaded after jquery load function call

When loading html content via $ .load, the html content contains tags <script>

referencing javascript files, associated Javascript files are added with the busting cache option that prevents the browser from caching the file.

So instead of <script src="/js/foo.js">

asking the type, it asks <script src="/js/foo.js?_=123123">

, calling the script load every time.

Is there a way to disable this behavior?

+3


source to share


1 answer


You can try to force the cache

$.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
});

      

+2


source







All Articles