Using LocalStorage with HTML5 - Load records only if needed

This is what I am trying to achieve,

  1. Call JSON Webservice to get data.
  2. Store the Data locally on the device.
  3. When the page is reloaded, check for the Local storage to get records,
    Call the WS only if there are no records locally.
  4. Display the results in the UI Web view.

Any help would be great.

Thanks,
C Data