2012-11-10 47 views
1

我與應用程序緩存的工作和我所面臨的問題如下:應用程序緩存在工作的Tomcat 6.0,但不是在weblogic 10.3

在Tomcat服務器:

當服務器處於聯機狀態,如果頁面被首次訪問,清單文件中指定的文件將被成功捕獲到應用程序緩存中。

當服務器處於離線狀態時,當我們嘗試訪問緩存頁面時,瀏覽器控制檯中出現錯誤(根據我在互聯網上的發現,這是非常正常的),但應用程序緩存正常工作。

在WebLogic Server:

我試圖運行在WebLogic Server相同的代碼,在聯機模式下,該文件均與預期緩存。但在離線模式下,第一次加載頁面時,它工作正常,但是當我看到控制檯時,應用程序緩存的狀態變爲OBSOLETE模式,所以如果我再次刷新頁面,它會拋出我一個404錯誤。另外,當我嘗試運行tomcat服務器中的代碼時,我沒有收到"Application Cache Error event: Manifest fetch failed (-1)"。請讓我知道我做錯了什麼。下面是這些文件:

的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> 

清單文件(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> 

回答

1

當瀏覽器遇到HTML標記清單線這問題就來了,它會嘗試從服務器下載的應用程序緩存文件。但是當服務器沒有這個文件時,它返回404錯誤,所以應用程序緩存進入OBSOLETE事件。

因此,在這種情況下,可能的原因是 1-您的服務器不包含此文件 2 - 如果你的服務器有這個文件,但沒有返回給瀏覽器,這種情況發生在服務器運行時,但您的應用程序實際上是未部署的。

因此,請嘗試停止服務器,而不是僅從服務器實例中取消部署應用程序。 希望它有效。

相關問題