質問

We are planning to use HTML 5's Application cache in our application for storing static content and some documents like a timetable. This timetable gets updated every week. Now in our application we need to display the last updated date of this timetable. Is it possible to get the created date or downloaded date of a file which is there in the application cache programmatically? Or is there some better way of doing this (we dont' want to save any information in the server side)? Could you please let me know?

役に立ちましたか?

解決

How about this approach. Use a regular AJAX GET and look at the Last-Modified header:

function getTimeStamp(url) {
    var xmlHttpReq = false;
    var self = this;
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    self.xmlHttpReq.open('GET', url, true);
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            log(self.xmlHttpReq.getResponseHeader("Last-Modified"));
        }
    }
    self.xmlHttpReq.send(null);
}

My test page seems to be working, but it's late and I may have messed it up.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top