Clouda框架会将各个package.js中描述的JS和CSS资源自动写入manifest文件形成离线缓存。 如果对于图片,音乐等其他文件也有离线缓存需求,可通过建立app.manifest文件进行描述。 在app.manifest中描述过的资源,Clouda框架在启动时会一并写入整体manifest文件中。
app.manifest文件应该建立在如下位置,与controller,publish等目录平级:
app/app.manifest
app.manifest文件的格式与w3c规定的manifest文件格式一致,见:http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html
注意:目前暂不支持SETTINGS:域
一个示例:
- CACHE MANIFEST
- # the above line is required
- # this is a comment
- # there can be as many of these anywhere in the file
- # they are all ignored
- # comments can have spaces before them
- # but must be alone on the line
- # blank lines are ignored too
- # these are files that need to be cached they can either be listed
- # first, or a "CACHE:" header could be put before them, as is done
- # lower down.
- images/sound-icon.png
- images/background.png
- # note that each file has to be put on its own line
- # here is a file for the online whitelist -- it isn't cached, and
- # references to this file will bypass the cache, always hitting the
- # network (or trying to, if the user is offline).
- NETWORK:
- comm.cgi
- # here is another set of files to cache, this time just the CSS file.
- CACHE:
- style/default.css