Chapter 15
Offline Applications
WHAT YOU WILL LEARN IN THIS CHAPTER:
- Storing files locally in an offline cache
- Storing data on the client using key-value storage
- Accessing a local SQL database with JavaScript
In the past, one of the key differences between native IOS apps and web apps was the ability of native apps to work with local and remote data, whereas web apps were limited to working only when a live connection was available. However, Safari on IOS has embraced support for HTML 5”s offline capabilities, enabling you to create web apps that work even when the user has no access to the Internet.
In this chapter, I walk you through these offline capabilities.
HTML 5 OFFLINE APPLICATION CACHE
Safari on IOS takes advantage of HTML 5”s offline application cache to enable you to pull down remote files from a web server and store them in a local cache. Consequently, when the device is not connected to the Internet, either through 3G or Wi-Fi access, users can continue to work with your web app in offline mode.
You can include any file in the manifest that can be displayed locally without server-side processing — images (.jpg, .png, and .gif), HTML files, CSS style sheets, and JavaScript scripts.
Safari then attempts to download files in the manifest. If successful, Safari on IOS looks for these files in the cache first before going to the server. However, in the event of a missing file, incorrect URL, or other error, the update process fails and no further files are downloaded. ...