2

I'm newbie to HTML 5 Application storage. Im trying a sample to test the offline storage. I have few questions. Please help.

Files used:

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>

style.css

body{background-color: #333;}
h1{color: #c94054;}
p{color: #fff;}

demo.manifest

CACHE MANIFEST

CACHE:
style.css
index.html

I know that demo.manifest MIME type has to be set to text/cache-manifest and this has to be done in the *.htaccess file. I'm using apache tomcat 6.0 server on a windows environment. I'm not able to find this file inside the server. So, I created one (test.htaccess) in the root directory of my project (which is being developed on eclipse helios) that is, in d:/eclipse-workspace/ProjectName/ and my file looks like below:

test.htaccess

AddType text/cache-manifest .manifest

But application cache does not work when I stop the server and tried to access it as below:

http://localhost:8081/ProjectName/index.html

Please let me know what have I done wrong with this...Also, Is there a way to debug application cache

0

2 Answers 2

6

On a Tomcat server the MIME types are configured via the default web.xml file, conf/web.xml

Towards the end of that file you'll find a bunch of defined MIME types. You have to add

<mime-mapping>
    <extension>manifest</extension>
    <mime-type>text/cache-manifest</mime-type>
</mime-mapping>

as the equivalent of what you'd put in .htaccess as used by Apache and other servers.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi..Thanks for the information. I had done this and still I get the below error in Google Chrome error log (opened the browser log by ctrl+shift+J) "Application Cache Error event: Invalid manifest mime type ()"
@user1475068 first of all check with the Chrome developer tools - Network tab what exactly gets transfered (esp. the mime type of course). Also check stackoverflow.com/questions/7375514/… as I think it's a related issue. Maybe a stupid question, did you restart Tomcat after adding the MIME type to its central web.xml?
Hi...I checked in the Network tab and I'm able to see the .css, .html and .js file but not my .manifest file. I had restarted the server as well before testing it. Also, in the post which you had said, the error message shows "text/plain" inside the brackets but in mine its just empty. What would be the correct location of the .htaccess file in windows. Do i have to refer this file elsewhere? Please help....
Hi..Finally, I had got this working. I changed the extension of the cache manifest file from .manifest to .appcache and now its working fine. Thanks for your help and suggestions.
@user1475068 glad I could help you solve your problem, good luck with your project!
|
0

I had the same problem. Everything looked right: paths were correct, the manifest was in my project and I could manually browse to it, MIME type was set. It simply wasn't attempting to get this file from my HTML. The problem was I hadn't included the required line at the beginning of the manifest:

CACHE MANIFEST

Not having this was causing the browser to just silently ignore the manifest tag.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.