HTML5应用程序缓存不适用于Firefox

时间:2016-07-19 15:06:59

标签: javascript html5 firefox offline application-cache

以下组合适用于IE,Chrome和Opera,但在Firefox上失败。 Firfox只是忽略了清单文件。

entry.html

<html manifest="manifest.php">
  <h1>Application Cache Example</h1>

  <script>
    function onUpdateReady() {
      console.log('found new version!');
    }
    window.applicationCache.addEventListener('updateready', onUpdateReady);
    if(window.applicationCache.status === window.applicationCache.UPDATEREADY) {
        onUpdateReady();
    }

    function update_picture() {
      document.getElementById('picture').src='messenger.png '
    }
  </script>
</html>

manifest.php

header('Content-Type: text/cache-manifest');

$lines = array();

$lines[] = 'CACHE MANIFEST';
$lines[] = '/picture1.gif';
$lines[] = '/picture2.gif';
$lines[] = '/picture3.gif';
$lines[] = '/picture4.gif';
$lines[] = '/picture5.gif';
$lines[] = '/picture6.gif';
$lines[] = '/picture7.gif';
$lines[] = '/picture8.gif';
$lines[] = '/picture9.gif';
$lines[] = '/picture10.gif';

echo implode("\r\n",$lines);

我正在试图解决过去4天的问题。只是无法理解为什么Firefox不想缓存图片。

欢迎任何想法,评论或解决方案。提前谢谢。

1 个答案:

答案 0 :(得分:0)

Manifest的段标题也应该是CACHE,NETWORK或FALLBACK。尝试添加它们,看看Firefox是否更好用。此外,清单中的所有文件都必须是可访问的。任何下载文件失败都可能导致删除应用程序缓存。

CACHE MANIFEST

# version 1

CACHE:
/picture1.gif
/picture2.gif

NETWORK:
*
相关问题