HTML5 offline" Application Cache Error event:Manifest fetch failed(-1)" [英] HTML5 offline "Application Cache Error event: Manifest fetch failed (-1)"

查看:173
本文介绍了HTML5 offline" Application Cache Error event:Manifest fetch failed(-1)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写HTML5离线应用程序,但似乎无法让Chrome接受缓存清单文件。



Chrome会将以下输出记录到其中控制台在加载应用程序时:

 使用清单创建应用程序缓存http://localhost/cache.manifest 
应用程序缓存检查事件
Application Cache错误事件:清单读取失败(-1)http://localhost/cache.manifest

但是,如果我从清单文件中除第一行(即CACHE MANIFEST)以外的所有行,Chrome会接受清单:



<$ p $使用清单创建应用程序缓存http://localhost/cache.manifest
应用程序缓存检查事件
应用程序缓存下载事件
应用程序缓存进度事件(0 of 0 )
应用程序缓存缓存事件

但是,只要我将新行添加到清单(即使下一行是空的)Chro我转而抱怨抓取失败。

所有文件都通过端口80上的SimpleHTTPServer通过Python从Windows 7 PC本地提供。我已经更新了types_map %PYTHON%/ Lib / mimetypes.py与以下行:

 '.manifest':'text / cache-manifest' ,

清单应包含以下内容:

  CACHE MANIFEST 
scripts / africa.js
scripts / main.js
scripts / offline.js
scripts / libs / raphael- min.js
favicon.ico
apple-touch-icon.png


解决方案

我现在通过切换到CherryPy来提供这些文件来解决这个问题:)

如果其他人变得类似卡住,但想要保持服务器部分简单,下面的Python对于入门可能就足够了:

  import cherrypy 


class SimpleStaticServer:

@ cherrypy.expose
def index(self):
return'< html>< body>< a href =index.html>进入静态索引页面< / a> < / body>< / html>'


cherrypy.config.update({
#global
'server.socket_host':'192.168.0.3 ',
'server.socket_port':80,

#/ static
'tools.staticdir.on':True,
'tools.staticdir.dir' :(存储静态文件的目录),
})
cherrypy.quickstart(SimpleStaticServer())

如果你想从另一台设备访问网站,你需要使用外部IP地址(对我来说这是192.168.0.3)。否则,您可以使用'127.0.0.1'作为'server.socket_host'值。然后,我将浏览器指向 http://192.168.0.3/index.html 以获取我的静态索引页。


I'm trying to write an HTML5 offline application but can't seem to get Chrome to accept the cache manifest file.

Chrome logs the following output to its console while loading the application:

Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Error event: Manifest fetch failed (-1) http://localhost/cache.manifest

However, if I remove all lines from the manifest file except for the first line (i.e. "CACHE MANIFEST") Chrome accepts the manifest:

Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 0)
Application Cache Cached event

But, as soon as I add a new line to the manifest (even if that next line is empty) Chrome reverts to complaining that the fetch failed.

All files are being served locally from a Windows 7 PC via Python using SimpleHTTPServer on port 80. I've updated the types_map in %PYTHON%/Lib/mimetypes.py with the following line:

    '.manifest': 'text/cache-manifest',

The manifest should contain the following:

CACHE MANIFEST 
scripts/africa.js
scripts/main.js
scripts/offline.js
scripts/libs/raphael-min.js
favicon.ico
apple-touch-icon.png

解决方案

I have now resolved this issue by switching to CherryPy for serving these files :)

If anyone else becomes similarly stuck but wants to keep the server part simple, the following Python may be sufficient for getting started:

import cherrypy


class SimpleStaticServer:

    @cherrypy.expose
    def index(self):
        return '<html><body><a href="index.html">Go to the static index page</a></body></html>'


cherrypy.config.update({
        # global
        'server.socket_host': '192.168.0.3',
        'server.socket_port': 80,

        # /static
        'tools.staticdir.on': True,
        'tools.staticdir.dir': "(directory where static files are stored)",
    })
cherrypy.quickstart(SimpleStaticServer())

If you want to visit the "site" from another device, you'll need to use the external IP address (for me this was 192.168.0.3). Otherwise, you can just use '127.0.0.1' for the 'server.socket_host' value. I then point my browser to http://192.168.0.3/index.html to get my static index page.

这篇关于HTML5 offline&quot; Application Cache Error event:Manifest fetch failed(-1)&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆