Offline storage, html5 offline storage

Source: Internet
Author: User

Offline storage, html5 offline storage

I. Support Detection

If (window. applicationCache) {// the browser supports offline storage} else {// the browser does not support offline storage} support: IE9 and earlier versions do not support
2. manifest File
  • Introduce the manifest file:
  • Manifest file format (Note ):
  • Cache manifest # The first line must be the cache manifestCACHE: # All the items to be cached must be placed in the CACHE: css/B .css # Always put requests from the NETWORK on the NETWORK: css/a.css FALLBACK # redirect css/c.css/a.css after access failure
    • CACHE: CACHE all specified files locally.
    • NETWORK: the specified file always requests the latest from the NETWORK.
    • FALLBACK: if the specified file cannot be found, it will be redirected to the new address.
Iii. Status
  • ApplicationCache. status
    • 0 === not cached
    • 1 === idle (the cache is in the latest status)
    • 2 === checking
    • 3 === downloading
    • 4 === Update ready
    • 5 === cache expiration
4. update: actively update the cache
// Update setInterval (function () {applicationCache. update () ;}, 5000) every 5 seconds );
5. Event updateready: when a new cache is available and the update is complete, the event progress event is triggered: when a new cache is in the process of downloading, this event will be continuously triggered.
  • The event objects in progress include loaded and total. Loaded indicates the files already loaded. total indicates the total number of files to be updated.
Other events:
  • Checking event: checking
  • Downloading event: downloading
  • Updatereadey event: update complete
  • Obsolete event: cache expiration
  • Cached event: idle, the cache is in the latest status
  • Error Event: error
  • Noupdate event: Check that the update is complete and no update is required.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.