【发布时间】:2011-01-26 18:08:07
【问题描述】:
我正在尝试将 iPhone 缓存为 HTML5 Web 应用程序,以便在使用时可以离线。网络应用程序位于 www.prism.gatech.edu/~gtg880f,但我没有成功。我借来试试看。
只有 3 个文件: 索引.html index.js 样式.css
我修改了 index.html 以包含 <html manifest="offline2.manifest">
和<meta content="yes" name="apple-mobile-web-app-capable" />,这样它就会像离线网络应用一样全屏显示。
我的offline2.manifest文件如下:
CACHE MANIFEST
index.html
index.js
style.css
debug.js
NETWORK:
CACHE:
PS:debug.js 来自Jonathan Stark。
当我使用 firefox 时,它会正确缓存它,并且我可以离线使用网络应用程序。但是,它在 chrome 和 safari 中都失败了。
在 Chrome 中,我收到以下调试消息:
Application Cache Checking event
Application Cache Error event: Invalid manifest mime type (text/plain) http://www.prism.gatech.edu/~gtg880f/offline2.manifest
我搜索了清单 mime 类型,它提到了一些关于 .htaccess 的内容,但我实际上不太确定这意味着什么。按照说明,我转到etc/apache2/httpd.conf 并将ALLOWOVERIDE ALL 从无更改。
这似乎并没有解决任何问题,我仍然收到相同的错误消息。
简而言之,我想做的就是使用 iPhone 上的 safari 浏览器访问 www.prism.gatech.edu/~gtg880f 并将其保存到我的主屏幕。然后,关闭 3G 和 wifi 并仍然使用网络应用程序。
编辑:尝试了 roryf 的第一个答案:
仍然不起作用。我想编辑/etc/apache2/httpd.conf 中的httpd.conf 文件吗?我正在使用 Mac OSX。我在这个部分下添加了它
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig /private/etc/apache2/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/cache-manifest manifest # added to allow HTML5 offline caching
【问题讨论】: