为什么我的 HTML5 应用程序缓存不工作?
我的设置/代码如下(顺便说一句,我正在遵循 nettuts 快速提示)
// index.html
<!DOCTYPE HTML>
<html lang="en-US" manifest="cache.manifest">
// cache.manifest
CACHE MANIFEST
# version 2
index.html
style.css
scripts.css
// httpd.conf (i tried having a local .htaccess too)
AddType text/cache-manifest .manifest
AddType text/cache-manifest manifest // i have this as its whats shown in the video. anyway even if i remove this it still fails.
更新:
从实时 HTTP 标头记录 @pastebin
http://localhost/cache.manifest
GET /cache.manifest HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0E) FirePHP/0.4
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost/
X-Moz: offline-resource
Pragma: no-cache
Cache-Control: no-cache
HTTP/1.1 200 OK
Date: Sat, 04 Sep 2010 03:14:16 GMT
Server: Apache/2.2.16 (Win32) PHP/5.3.3
Last-Modified: Sat, 04 Sep 2010 03:14:09 GMT
Etag: "700000000238e-42-48f6670db41b9"
Accept-Ranges: bytes
Content-Length: 66
Keep-Alive: timeout=5, max=94
Connection: Keep-Alive
Content-Type: text/cache-manifest
我看到了吗最后一行? Content-Type:text/cache-manifest
或第 6 个 接受:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8< /代码>。
我认为它现在可以工作,但是如果我有来自 google cdn 的 jquery,它将无法在第二次刷新时工作,我认为它只尝试使用本地文件?
i have my setup/code as follows (btw, i am following the nettuts quick tip)
// index.html
<!DOCTYPE HTML>
<html lang="en-US" manifest="cache.manifest">
// cache.manifest
CACHE MANIFEST
# version 2
index.html
style.css
scripts.css
// httpd.conf (i tried having a local .htaccess too)
AddType text/cache-manifest .manifest
AddType text/cache-manifest manifest // i have this as its whats shown in the video. anyway even if i remove this it still fails.
update:
log from Live HTTP Headers @pastebin
http://localhost/cache.manifest
GET /cache.manifest HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729; .NET4.0E) FirePHP/0.4
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost/
X-Moz: offline-resource
Pragma: no-cache
Cache-Control: no-cache
HTTP/1.1 200 OK
Date: Sat, 04 Sep 2010 03:14:16 GMT
Server: Apache/2.2.16 (Win32) PHP/5.3.3
Last-Modified: Sat, 04 Sep 2010 03:14:09 GMT
Etag: "700000000238e-42-48f6670db41b9"
Accept-Ranges: bytes
Content-Length: 66
Keep-Alive: timeout=5, max=94
Connection: Keep-Alive
Content-Type: text/cache-manifest
do i see the last line? Content-Type: text/cache-manifest
or the 6th Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
.
i think it works now, but if i have jquery from the google cdn, it will not work on 2nd refresh, i think it tries to use local files only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个外部资源(无论是在您的域还是其他域上)都必须在清单中说明。如果想使用 google 的 jQuery cdn,您必须在清单文件中引用它。像这样的事情:
在清单的末尾,我通常包含以下行来说明我未列出但可能使用的任何资源。仅当有网络连接时才使用它们:
Every external resource (whether it's on your domain or another) must be accounted for in the manifest. If want to use google's jQuery cdn, you must reference it in your manifest file. Something like this:
At the end of my manifests, I usually include the following line to account for any resources that I haven't listed but might be used. It only uses them if there is a network connection: