问题
I'm getting a bit confused by the (varied) terminology for HTML5 offline storage.
I think that AppCache is another name for Web Storage and you specify what will be stored offline via the Cache Manifest. And there are two types: LocalStorage (persists beyond the current session) and session storage (which does not persist beyond the current session).
The above is what I'm reading from W3C and from wikipedia but Head First HTML5 Programming (Freeman & Robinson) describes LocalStorage in depth, then has Web Storage (with info on Cache Manifest) in the appendix ("things we aren't covering).
Am I understanding this correctly?
回答1:
WebStorage is the possibility in HTML5 to store data on client side (think of it like cookies, but with usually 5 MB available space). The're two ways to store that data (scope):
- Just for a session until the browser get closed (SessionStorage)
- For a longtime period even if the browser get closed and the host's shutdown
http://diveintohtml5.info/storage.html
AppCache is the HTML5-ability to store the whole web-app (pages, images, css, JavaScript) in the browser to make it available even if the client has no internet connection at all.
http://appcache.offline.technology/
回答2:
LocalStorage:
- LocalStorage is used to save intermediate data in client side without using cookies.
- Saves data in the form of key-value pairs
- Saved data persists in the browser until it is explicitly removed. If not removed, it will be available for years.
- Memory 5Mb
AppCache:
- HTML5 applications offers offline application feature by saving html page and related files(css, js..) locally in appCache. These files will be used to render page when network connection is not available. Application will have manifest file containing list of files to be dowloaded to render offline application feature. If there is a change in manifest file(any file is added/removed from application), then new set of files will be downloaded. Old file will be replaced by new the ones once reload is clicked.
- Saves files as data - html, js, css,etc
- Saved data will be available until reload is clicked or until browser is closed.
- Memory varies based on browser. See http://grinninggecko.com/2011/02/24/developing-cross-platform-html5-offline-app-1/
来源:https://stackoverflow.com/questions/10986026/is-appcache-application-cache-web-storages-localstorage