質問

I'm working with application cache and I'm facing the below issue:

In Tomcat Server:

When the server is online and if the page is accessed for the first time, the files specified in the manifest file are caught successfully in the application cache.

When the server is offline, when we try to access the cached page, there is an error in the browser console (Application Cache Error event: Manifest fetch failed (-1) which is quite normal as per my findings in the internet) but the application cache works fine.

In Weblogic server:

I tried to run the same code in Weblogic server, in online mode, the files are cached as expected. But in the offline mode, for the first time the page is loaded, it works fine, but when I see the console the status of the application cache goes to OBSOLETE mode and so if I do a refresh of the page again, it throws me a 404 error. Also, I'm not getting the "Application Cache Error event: Manifest fetch failed (-1)" which I get when I try to run the code in tomcat server. Please let me know what's that I'm doing wrong. Below are the files:

index.html

<html manifest="demo.appcache"> 
<head> 

<link rel="stylesheet" href="style.css" type="text/css" /> 

<script type="text/javascript" src="script.js" ></script>


</head> 
<body> 
<h1>Basic example of page using Application Cache</h1> 
<p>Disconnect from the internet and try to reload this page. It should load without requiring you to connect to the internet.</p> 
</body> 
</html>

manifest file (demo.appcache)

CACHE MANIFEST

CACHE:
style.css
script.js
index.html
demo.appcache

NETWORK:
*

style.css

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

script.js

if (!window.applicationCache){
    alert('It seems that Application Cache is not supported in this browser. Please use a browser which supports it.');
}

web.xml

<mime-mapping>
     <extension>appcache</extension>
     <mime-type>text/cache-manifest</mime-type>
     </mime-mapping>
役に立ちましたか?

解決

This problem comes when the browser encounters the manifest line in the html tag, it tries to download the appcache file from the server. But when the server doesn't have this file it returns 404 error, so the application cache goes to OBSOLETE event.

So in this case, the possible reasons are 1- your server doesn't contain this file 2 - If your server has this file but not returning to the browser, this happens when the server is running but your application is actually undeployed.

So try stopping your server rather than just undeploying your applciation from the server instance. Hope it works.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top