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

发布于 2024-09-17 01:18:45 字数 1795 浏览 0 评论 0原文

我的设置/代码如下(顺便说一句,我正在遵循 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傻比既视感 2024-09-24 01:18:46

我认为它现在有效,但如果我有
来自 google 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:
*

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?

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:

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

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:

NETWORK:
*
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文