为什么我的HTML5应用程序缓存不起作用?

时间:2010-09-03 08:33:19

标签: html5 offlineapps application-cache

我的设置/代码如下(顺便说一下,我跟随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. 

更新

从实时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 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

我认为它现在有效,但如果我有来自谷歌cdn的jquery,它将无法在第二次刷新,我认为它只尝试使用本地文件?

1 个答案:

答案 0 :(得分:0)

  

我认为它现在有效,但如果我有   来自谷歌cdn的jquery,它会   我认为不适用于第二次刷新   尝试仅使用本地文件?

每个外部资源(无论是在您的域上还是其他外部资源)都必须在清单中进行说明。如果想使用google的jQuery cdn,则必须在清单文件中引用它。像这样:

https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js

在我的清单结束时,我通常会包含以下行来说明我未列出但可能会使用的任何资源。它只在有网络连接时才使用它们:

NETWORK:
*