我正在尝试编写HTML5离线应用程序,但似乎无法让Chrome接受缓存清单文件.
在加载应用程序时,Chrome会将以下输出记录到其控制台:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Error event: Manifest fetch failed (-1) http://localhost/cache.manifest
Run Code Online (Sandbox Code Playgroud)
但是,如果我从清单文件中删除除第一行之外的所有行(即"CACHE MANIFEST"),则Chrome接受清单:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 0)
Application Cache Cached event
Run Code Online (Sandbox Code Playgroud)
但是,只要我向清单添加一个新行(即使下一行为空),Chrome也会回复抱怨提取失败.
所有文件都是通过端口80上的SimpleHTTPServer通过Python从Windows 7 PC本地提供的.我使用以下行更新了%PYTHON%/ Lib/mimetypes.py中的types_map:
'.manifest': 'text/cache-manifest',
Run Code Online (Sandbox Code Playgroud)
清单应包含以下内容:
CACHE MANIFEST
scripts/africa.js
scripts/main.js
scripts/offline.js
scripts/libs/raphael-min.js
favicon.ico
apple-touch-icon.png
Run Code Online (Sandbox Code Playgroud)