Skip to content
benzado edited this page Jun 29, 2011 · 2 revisions

Since the app needs to support working offline (e.g. at UCB), it should use the HTML5 offline storage spec. In order to implement this, a caching strategy should be used. Below is a basic example.

Each time the mobile app is launched (and has a connection) it requests data from the webapp by sending the hash it currently has (or a null value). Then the webapp can generate the json, calculate a hash (saving it for quick lookup if desired), and send a response if anything has changed. This will cut down on raw data transfer when unnecessary.

Ben: While I agree that this is generally a good architecture for fetching data, I think we should design around the fact that the schedule will not be changing very often (if at all) and, when it does, it is fairly simple to just dump the local copy and download a new one. In that case, won't it be easier to just put a static file on the server, and use If-Modified to decide when we need an update?

The response is structured similar to the request. The hashes should also be cached (as opposed to generating in the mobile app itself), due to the potential for differences in the json data (jQuery automatically converts json to a native object, while the PHP app will be working with a string.

request = {
  shows : hash || null,
  schedules : hash || null,
  venues : hash || null
}

response = {
  shows : {
    hash : "md5 hash of json object generated by php",
    data : []
  },
  schedules : {
    hash : "md5 hash of json object generated by php",
    data : []
  },
  venues : {
    hash : "md5 hash of json object generated by php",
    data : []
  }
}
Clone this wiki locally