gpt4 book ai didi

javascript - 执行 html5 webapp 缓存时出现问题

转载 作者:太空宇宙 更新时间:2023-11-04 13:26:07 27 4
gpt4 key购买 nike

我有一个域为 http://draft.mo2do.com 的网络应用程序

当我访问该 url 时,它将像下面的 url 一样解析并重定向到相应的站点主页

http://draft.mo2do.com/s/_91665/Home

这里我实现了离线缓存。我的 cache.manifest 文件如下

   CACHE MANIFEST
# Offline cache v4.0

# All other resources (e.g. sites) require the user to be online.

NETWORK:

*

# Additional resources to cache CACHE:

# Add the pages in to the cache

/s/_91665/Home /s/_91665/CachedDraftBoard

http://draft.mo2do.com

# Add the images in to the cache

/s/store/-1/webapp/styles/webapp.css

/s/store/-1/webapp/styles/nba_draft.css

/s/store/-1/webapp/styles/add2drafthome.css?v2

# Add the js files in to the cache

/s/store/-1/webapp/scripts/jquery-1.5.min.js

/s/store/-1/webapp/scripts/iscroll.js

/s/store/-1/webapp/scripts/webapp.js

/s/store/-1/webapp/scripts/nba_draft.js

/s/store/-1/webapp/scripts/cacheUpdate.js

/s/store/-1/webapp/scripts/add2drafthome.js?v0.9.4



/webapp/icon.png /webapp/startup.png

/s/store/-1/webapp/nba/addtodrafthome/arrow.png

/s/store/-1/webapp/nba/addtodrafthome/close-bubble.png

/s/store/-1/webapp/nba/addtodrafthome/icon.png

/s/store/-1/webapp/nba/addtodrafthome/plus.png

/s/store/-1/webapp/nba/addtodrafthome/share.png

FALLBACK:

http://draft.mo2do.com

如果我直接访问站点 url,缓存工作正常,那时候我没有在缓存部分提到“http://draft.mo2do.com”。在此期间,离线缓存工作正常。

如果我在浏览器中直接访问域 url“http://draft.mo2do.com”,它不会在离线模式下打开 404。

然后我在缓存部分添加了“http://draft.mo2do.com”,当时我遇到了异常

应用程序缓存进度事件(第 2 个,共 3 个)http://draft.mo2do.com/应用程序缓存错误事件:资源获取失败 (-1) http://draft.mo2do.com/

如果我访问该域,它也应该在离线模式下加载应用程序。如果我访问直接 url 应用程序加载正常。

我该如何解决这个问题?

最佳答案

缓存必须直接引用特定资源,无论是 Javascript、CSS、HTML 页面、图像等等。从上面的内容我可以看出,你已经做到了。然而,简单地在其中放置一个域是行不通的(您还需要引用所有您想要离线的页面,例如 /s/_91665/Home 需要在那里)。

所以,这条线的某处有错误,但很难弄清楚你的意思:

If i directly access only the domain url "http://draft.mo2do.com" in the browser it is not opening 404 in the offline mode.

你能说的清楚点吗?您的意思是转到该 URL 会导致 404,还是页面本身存在错误?

您确定您的缓存文件按预期运行吗? 如果缓存文件中有任何错误,您的离线应用程序将无法运行。此页面提供了一些可能有帮助的调试代码:

Debugging HTML 5 Offline Application Cache

关于javascript - 执行 html5 webapp 缓存时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6677813/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com