开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜