Html5应用程序缓存:刷新页面

时间:2016-08-18 03:19:17

标签: html5 cache-manifest

我在Android Chrome浏览器和桌面Chrome浏览器上进行了一些Html5应用程序缓存测试。

清单网址
/ appcachetest /主要/ AppManifest:

CACHE MANIFEST

# Version: 3

NETWORK:
*

CACHE:
Main
Main/Page1
Main/Page2
Scripts/jquery-1.10.2.js
#FALLBACK:
@{
   Layout = null;
   Response.ContentType = "text/cache-manifest";
   Response.Cache.SetCacheability(HttpCacheability.NoCache);
   Response.Cache.SetExpires(DateTime.MinValue);
  Response.ContentEncoding = System.Text.Encoding.UTF8;
 }

主要索引页面:

<!DOCTYPE html>
<html manifest="/appcachetest/Main/AppManifest" type="text/cache-manifest">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - My ASP.NET Application</title>
    <script src="/AppCacheTest/Scripts/jquery-1.10.2.js"></script>
</head>
<body>


<iframe src="Main/Page1" style="border: 0; width: 100%; height: 100%">   </iframe>

</body>
</html>

我尝试了以下步骤:

  1. 使浏览器在线。
  2. 在地址栏中输入主索引页面Url,然后按Enter
  3. 正确加载页面,并缓存所有项目。
  4. 关闭浏览器并重新启动。
  5. 使浏览器脱机并启用缓存。
  6. 在地址栏中键入主索引页面并按Enter键。
  7. 从缓存加载的主索引页面和JavaScript文件。
  8. 单击浏览器刷新按钮,然后无法从缓存加载JavaScript文件。
  9. 刷新页面时是否有任何可用的解决方案从应用程序缓存中加载JavaScript文件?如何使它工作?

    谢谢, 博

2 个答案:

答案 0 :(得分:1)

经过几个小时的调查和测试。

我发现如果我将文件jquery-1.10.2.js重命名为jquery.js.jgz,那么离线刷新页面不会导致任何错误。

答案 1 :(得分:0)

我终于知道导致无法从Manifest Cache加载JavaScript文件的问题。

Manifest文件中的缓存URL区分大小写,直到花了两天时间我才意识到这一点。