我正在嘗試向我維護的應用添加一些脫機緩存。這是我第一次不得不使用AppCache,所以我決定首先用一個小型演示站點來測試它。目前爲止,我還沒有能夠使其脫機部分正常工作。儘管我在腳本中發送了所有這些無緩存標頭,但Chrome瀏覽器似乎緩存了index.php,因爲打印出來的日期/時間從未在頁面上發生變化,儘管在Firefox中日期正確更新。當我去下線(禁用我的網絡適配器)的Chrome繼續顯示緩存的index.php,而不是由清單中指定,但我發現了以下錯誤在控制檯offline.html:無法正常使用HTML5 AppCache
應用緩存錯誤事件:清單下載失敗(-1) http://html5test.g1testserver/manifest.appcache
火狐只顯示「無法連接」對話框。網站的佈局和文件內容全部列在下面。
網站佈局:
/root/
- manifest.appcache
- index.php
- offline.html
- .htaccess
manifest.appcache:
CACHE MANIFEST
# version 3
CACHE:
offline.html
NETWORK:
index.php
FALLBACK:
/offline.html
的index.php:
<?php
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo '<!DOCTYPE html>
<html manifest="/manifest.appcache">
<head>
<title>HTML5 Test</title>
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE" />
</head>
<body>
<h1>This is index.php: '.date('d/m/Y H:i:s').'</h1>
</body>
</html>
';
?>
offline.html:
<!DOCTYPE html>
<html manifest="/manifest.appcache">
<head>
</head>
<body>
<h1>This will be served in place of index.php</h1>
</body>
</html>
周
的.htaccess:
AddType text/cache-manifest .appcache
我覺得後備只被調用一些偉大的信息,如果緩存是不成功http://www.html5rocks.com/en/tutorials/appcache/beginner/ - 有在這裏是一個非常有用的部分。 Chrome的資源/應用程序緩存有什麼內容? – JonWells
@CrimsonChin:offline.html,index.php和manifest.appcache在資源 – hellsgate
中列出,如果您不想index.php緩存,然後從標記中刪除清單屬性「瀏覽器不緩存頁面,如果它不包含清單屬性(除非它明確列在清單文件本身中),瀏覽器仍然會緩存清單中的所有其他內容 – JonWells