本来想翻译dive into html5的,后来发现老外写书都超长超啰嗦… 不如写step by step吧…
1.add content type (or set content-type in your cgi script)
apache: AddType text/cache-manifest .manifest
lighttpd in mimetype.assign : “.manifest” => “text/cache-manifest”
2.write cache-manifest file
cache.manifest:
CACHE MANIFEST
#comment,files that can be cached
/static/img/logo.gif
NETWORK:
/js/weather.js
3.write html
<!DOCTYPE html>
<html manifest=”/static/img/html5/cache.manifest”><head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/>
… …
All done! Try it in your FireFox or iPhone, when u refresh your page, there should be only one http request sent (the one listed under NETWORK).
Trouble shoot:
Q: i seems i can’t update the content of the page, it doesn’t work ?
A: change the content of cach.manifest file (e.g change some comment),and the page would be updated itself.
CACHE MANIFEST
#rev 10
/static/img/logo.gif
NETWORK:
/js/weather.js
Learn By Example:
http://www.google.com/m?manifest=1
http://m.hao123.com/static/img/html5/cache.manifest
More:
http://diveintohtml5.org/offline.html
BTW:这个玩意用在iPhone上超爽, 页面打开速度非常快. 如果要做web app的话是不二的选择~