HTML5中的应用程序缓存不起作用:

CAR*_*TIC 2 html5

我是HTML 5应用程序存储的新手.我正在尝试一个示例来测试离线存储.我几乎没有问题.请帮忙.

使用的文件:

的index.html

<html manifest="demo.manifest"> 
<head> 
<link rel="stylesheet" href="style.css" type="text/css" /> 
<script type="text/javascript" src="script.js" ></script>
</head> 
<body> 
<h1>some text</h1> 
<p>Some text.</p> 
</body> 
</html>
Run Code Online (Sandbox Code Playgroud)

style.css文件

body{background-color: #333;}
h1{color: #c94054;}
p{color: #fff;}
Run Code Online (Sandbox Code Playgroud)

demo.manifest

CACHE MANIFEST

CACHE:
style.css
index.html
Run Code Online (Sandbox Code Playgroud)

我知道demo.manifest MIME类型必须设置为text/cache-manifest,这必须在*.htaccess文件中完成.我在Windows环境中使用apache tomcat 6.0服务器.我无法在服务器中找到此文件.所以,我在我的项目的根目录中创建了一个(test.htaccess)(在eclipse helios上开发),在d:/ eclipse-workspace/ProjectName /中,我的文件如下所示:

test.htaccess

AddType text/cache-manifest .manifest
Run Code Online (Sandbox Code Playgroud)

但是,当我停止服务器并尝试访问它时,应用程序缓存不起作用,如下所示:

http://localhost:8081/ProjectName/index.html
Run Code Online (Sandbox Code Playgroud)

请让我知道我做错了什么...另外,有没有办法调试应用程序缓存

fvu*_*fvu 6

在Tomcat服务器上,MIME类型通过默认的web.xml文件进行配置, conf/web.xml

在该文件的末尾,您将找到一堆已定义的MIME类型.你必须添加

<mime-mapping>
    <extension>manifest</extension>
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>
Run Code Online (Sandbox Code Playgroud)

与Apache和其他服务器使用的.htaccess相同.