开发者

Can I get via javascript the HTTP expires header of a HTTP resource?

开发者 https://www.devze.com 2022-12-16 18:40 出处:网络
My page开发者_开发百科 needs to know when the cache a included javascript file will expire, to retrieve it again.The XMLHTTPRequest object has a getResponseHeader method you can call:

My page开发者_开发百科 needs to know when the cache a included javascript file will expire, to retrieve it again.


The XMLHTTPRequest object has a getResponseHeader method you can call:

// The following script:
var client = new XMLHttpRequest();
client.open("GET", "test.txt", true);
client.send();
client.onreadystatechange = function() {
    if (this.readyState == 2) {
        alert(client.getResponseHeader("Expires"));
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号