HTML 5 离线存储缓存清单不起作用
我正在尝试让 HTML5 离线存储以基本方式工作。我阅读了 DiveIntoHTML5 上的信息,它似乎很有意义,但它似乎不起作用为我。我想知道是否有人可以帮我调试这个。
基本上我已经为应用程序设置了一个主页,index.htm。所以我的申请在网上 http://www.mydomain.com/online/index.htm 。用户将访问此页面,他们通常会在其中完成所有日常工作。访问此 URL 将创建一堆缓存文件,以便他们可以访问 http://www.mydomain.com/offline< /a> 并在离线时查看应用程序的工作版本。
在线主页的前几行代码是:
<!DOCTYPE html>
<html manifest="cache.manifest">
<head>
...etc
我生成了一个名为“cache.txt”的纯文本文件,并在记事本中添加了以下内容:
CACHE MANIFEST
http://www.mydomain.com/offline/scripts/jquery-1.6.3.min.js
http://www.mydomain.com/offline/scripts/jquery-ui-1.8.16.custom.min.js
http://www.mydomain.com/offline/scripts/modernizr.min.js
http://www.mydomain.com/offline/scripts/json2.min.js
http://www.mydomain.com/offline/scripts/jquery.deserialize.js
http://www.mydomain.com/offline/scripts/jquery.cookie.js
http://www.mydomain.com/offline/scripts/main.js
http://www.mydomain.com/offline/css/main.css
http://www.mydomain.com/offline/css/structure-details.css
http://www.mydomain.com/offline/css/ui-lightness/jquery-ui-1.8.16.custom.css
http://www.mydomain.com/img/header.gif
http://www.mydomain.com/offline/img/bg.png
http://www.mydomain.com/offline/img/header_riser.gif
http://www.mydomain.com/offline/img/logo.png
http://www.mydomain.com/offline/img/offline.png
http://www.mydomain.com/offline/index.htm
然后,我将此文件重命名为“cache.manifest”并将其上传到在线应用程序的根目录(与我的主页处于同一级别),以便可以通过 http://www.mydomain.com/online/cache.manifest。
据称,托管公司已将“text/cache-manifest”内容类型添加到 IIS 中扩展名为 .manifest 的所有文件中。我认为这是有效的,因为当我在 Firefox 中查看文件时 http://www.mydomain.com /online/cache.manifest Firebug 告诉我内容类型是:
Content-Type cache-manifest
或者应该返回“text/cache-manifest”?也许这就是问题所在?
当我查看系统上的脱机存储文件夹时(C:\Users\Me\AppData\Local\Mozilla\Firefox\Profiles\b12u6xza.default,其中根本没有任何与此域相关的内容。
任何人都可以建议可能出了什么问题吗? - 因为我有点困惑?
I'm trying to get HTML5 offline storage working in a basic way. I read the information on DiveIntoHTML5 and it seems to make sense, but it just doesn't seem to be working for me. I wondered if someone could help me to debug this.
Basically I've set up a home page for the application, index.htm. So my application is on the web at http://www.mydomain.com/online/index.htm. Users will visit this page, where they'll ordinaraily do all of their stuff day-to-day. Visiting this URL will create a bunch of cached files so they can then visit http://www.mydomain.com/offline and view a working version of the application when they're offline.
The top few lines of code in the online homepage are:
<!DOCTYPE html>
<html manifest="cache.manifest">
<head>
...etc
I've generated a plain text file called 'cache.txt' and added the following content to it in Notepad:
CACHE MANIFEST
http://www.mydomain.com/offline/scripts/jquery-1.6.3.min.js
http://www.mydomain.com/offline/scripts/jquery-ui-1.8.16.custom.min.js
http://www.mydomain.com/offline/scripts/modernizr.min.js
http://www.mydomain.com/offline/scripts/json2.min.js
http://www.mydomain.com/offline/scripts/jquery.deserialize.js
http://www.mydomain.com/offline/scripts/jquery.cookie.js
http://www.mydomain.com/offline/scripts/main.js
http://www.mydomain.com/offline/css/main.css
http://www.mydomain.com/offline/css/structure-details.css
http://www.mydomain.com/offline/css/ui-lightness/jquery-ui-1.8.16.custom.css
http://www.mydomain.com/img/header.gif
http://www.mydomain.com/offline/img/bg.png
http://www.mydomain.com/offline/img/header_riser.gif
http://www.mydomain.com/offline/img/logo.png
http://www.mydomain.com/offline/img/offline.png
http://www.mydomain.com/offline/index.htm
I've then renamed this file to 'cache.manifest' and uploaded it to the root of the online application (at the same level as my home-page) so that it's accessible at http://www.mydomain.com/online/cache.manifest.
The hosting company have supposedly added the content type of 'text/cache-manifest' to all files with the extension of .manifest in IIS. I think this is working because when I view the file in Firefox at http://www.mydomain.com/online/cache.manifest Firebug tells me the content type is:
Content-Type cache-manifest
Or should this be returning 'text/cache-manifest'? Perhaps this is the problem?
When I view the offline storage folder on my system (C:\Users\Me\AppData\Local\Mozilla\Firefox\Profiles\b12u6xza.default there's nothing in there related to this domain at all.
Can anyone suggest what might be going wrong - as I'm a little stumped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,规范已更改,您现在应该使用
.appcache
作为清单扩展。其次,mime 类型应该按照您所说的
text/cache-manifest
进行定义。我与 IIS 并没有真正的关系,但似乎有两种方法可以添加此 MIME 类型,或者通过 IIS 管理 UI 或通过 web.config 文件另外,我建议您使用 Google Chrome 进行测试,因为它的控制台显示所有清单解析数据和错误,包括未正确识别清单 MIME 类型的情况。
First of all, the specification have changed, you should now use
.appcache
as manifest extension.Second, the mime type should be defined as you say
text/cache-manifest
. I'm not really related to IIS but seems like there's two ways to add this MIME type , either trough IIS administration UI or via web.config fileAlso, I would recommend you testing this with Google Chrome, since its console show all the manifest parsing data and errors, including when the manifest MIME type is not being correctly recognized.
您必须注意一些问题:
如果我发现更多问题,我会写下来。
问候。
There are some issues you have to be care about:
If I find more issues, I'll write it down.
Regards.
我在这上面花了很多时间(在我自己的问题上),离线缓存不起作用。尽我所能,更改缓存文件名,通过 htaccess 添加处理程序,将文件从本地上传到实时服务器,仍然是同样的问题。我自己终于从这个问题中得到了一些帮助。
我在 safari 中测试了它并且工作正常。 问题出在 Chrome 浏览器上。我也按照另一个用户的建议尝试了 https,但这也没有解决问题。因此,chrome 中可能有一个扩展禁止它使用缓存文件。在解决问题之前,首先在标准浏览器 Safari、FireFox、IE、Opera 中进行测试。不要在非标准浏览器(例如 Brave)中测试,它在其中不起作用。
来自 google 的官方消息
确认在版本 61 及更高版本中弃用。我跑80了
注意:HTML5 缓存已被弃用,
所有浏览器都将放弃此功能,我注意到它们在任何最新的浏览器中都不起作用。 MDN Mozilla 强烈建议不要使用它。
I spend a lot of time on this (on my own problem), offline cache was not working. Did everything possible I could do, changed cache file name, added handler via htaccess, uploaded the file from local to live server, still the same problem. Finally got some help from this question myself.
I tested it in safari and it was working fine. The problem was Chrome browser. I also tried https as another user suggested, that also did not fix the problem. So may be there is an extension in chrome that is forbidding it from using the cache file. Before troubleshooting your problem first test it in standard browsers Safari, FireFox, IE, Opera. Do not test in non-standard browsers such as Brave, it did not work in it.
Officially from google
Which confirms deprecation in Ver 61 and onward. I am running 80.
Note : HTML5 Cache is being deprecated
All browsers are going to drop this feature, I noticed they are not working in any of the latest browsers. This MDN Mozilla strongly advises against it and not to use it.
尝试在 httpd.conf 中添加这些行..这可能会帮助你
try to add these lines in httpd.conf ..this might help you
你最好使用chrome的控制台进行测试!(你在chrome的网络中看不到这些)
我的例子(访问:www.mustrank.com/views/1.php)。
看下面chrome的控制台输出,首先创建清单文件“website.appcache”,然后下载源文件“1.html”和“main.css”
You'd better test using chrome's console !(you can't see these in chrome's network)
My example(visit:www.mustrank.com/views/1.php ).
Look at chrome's console output below,manifest file "website.appcache" is created first,and then sources "1.html" and "main.css" are downloaded