My page needs to know when the cache a included javascript file will expire, to retrieve it again.
+2
A:
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"));
}
}
Gumbo
2010-01-15 19:01:46
Note you can use `HEAD` rather than `GET` if you just want the header info to avoid downloading the whole file, and it is probably best to call `client.send();` *after* you have assigned the `onreadystatechange` event handler.
RedFilter
2010-01-15 19:20:02