To use the manifest cache, we first need to write a manifest file. This file has strict formatting requirements, here is an exampleCACHE MANIFEST
#我是注释,这个文件名叫test.manifest
CACHE:
/test.css
/test.js
This is a simple manifest file. The first must be "CACHE MANIFEST" to declare that this is a MANIFEST file. The following "cache:" is the type of operation, and then the two files followed by the path is the "cache:" Action type of the file, indicating that these files need to be cached. Of course, the type of operation is more than the cache one, which is later. First of all, let's talk about the most important issues. How can the manifest file be used?
Use the manifest file as long as you add an attribute "manifest=" manifest file path "" to the HTML tag of the page, such as< HTMLManifest="test.manifest">
< head>
< linkhref="Test.css"rel="stylesheet" />
< scriptsrc="Test.js"></script>
>
< body>
< div>Cobalt (II) carbonate</div>
< body>
>
This page uses the manifest file written above, and we can use Chrome to open this page to find the manifest job information in the console.
As you can see from this message, the two files we set up that need to be cached are cached. and the page referencing manifest is also cached. This is important, this is the manifest mechanism, in addition to caching the set of files, but also the current reference to the manifest file page (want to shut off). Therefore, it is inconvenient to use, which requires attention.
In addition, the manifest cache will only be updated when the manifest file changes (as if the MD5 of this file has changed). The browser is not going to get the new file when the cached file is updated. That is, the page has just been cached test.css, and now I have modified the TEST.CSS, the page will not have any changes. Unless I modify the contents of the manifest file itself (note the content, not the modification time). In general, in order to update this cache, you can update it by putting the modification time in the comments inside. I can't do this, it's troublesome.
To finish these questions, now look back at the manifest itself. In addition to the "CACHE:" Above, there are several types of operations. Here are the operation types and descriptions
CACHE:Set the following file to cache
NETWORK:The following file is not cached (Cannot set itself page)
FALLBACK:Use another file when the file is wrong or does not exist
SETTINGS:can set fast or Prefer-online two modes
The cache is set up for caching, as has been said before.
Network is set without caching. Since the manifest mechanism is to store the entire page (or Web App) locally. Therefore, all resources used by the current page must have a setting. If not set, it will not be found after the page cache, so it is often necessary to use the network to match all resources that do not need to be cached, as in the following.CACHE MANIFEST
NETWORK:
*
Fallback is not present is replaced with another file, here is an exampleCACHE MANIFEST
#test.manifest
FALLBACK:
/x.css /test.css
< HTMLManifest="test.manifest">
< head>
< linkhref="X.css"rel="stylesheet" />
>
>
Since X.CSS does not exist, the cache uses TEST.CSS instead.
The settings can be set in two modes, the default is fast. But I didn't feel the difference between the two modes in my test, and this is not the case.
These are the most basic things about the manifest cache, and a big problem is the Firefox warning. When using manifest, a warning will appear under Firefox.
This is the place where the egg hurts the most, so let's get to the bottom of this thing and not go into it. After all these problems have been solved in coming back to see the goods. In fact, the role of manifest is to localize the Web application, if only to do "Web application localization", it can be used. But this thing is really not a force in other ways. So the current project will not consider the party pain of the thing. So much of it is just an entry-level test, and there's a lot of stuff to test. But because it is not available now, it is not studied for the time being.
HTML5 's manifest cache