Google Hosted Libraries is unnecessarily using cache breakers

I am using the following code on our dashboard to refresh it constantly without flicker How can I refresh a page with jQuery? :

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
setTimeout(function() {
    $.ajax({
        url: "",
        context: document.body,
        success: function(s,x){
            $(this).html(s);
        }
    });
}, 4000);
</script>

However, this is causing the javascript to reload each time too due to some cache breakers.

在这里输入图像描述

Google is sending with the following headers:

在这里输入图像描述

In the interest of not getting myself and my clients blocked from Google (might as well become a Mennonite at that point) is there a way use Google CDN without causing these extra requests?


Warning untested:

$.ajax({
    url: "",
    dataType: "text", //dont parse the html you're going to do it manually
    success: function(html) {
        var $newDoc = $.parseHTML(html, document, false); //false to prevent scripts from being parsed.
        $('body').replaceWith(newDoc.find("body")); //only replace body
    }
});

A better solution would be to template your body.

链接地址: http://www.djcxy.com/p/4906.html

上一篇: 在ajax HTML响应中查找body标签

下一篇: Google托管图书馆不必要地使用缓存破坏者