【问题标题】:net::ERR_FAILED for network item in manifest.cachenet::ERR_FAILED 用于 manifest.cache 中的网络项
【发布时间】:2016-09-27 18:28:56
【问题描述】:

我的缓存清单文件如下所示:

CACHE MANIFEST

calendar.html
scripts/jquery.js
scripts/calendar.js

NETWORK:

https://apis.google.com/js/client.js

我的 calendar.html 看起来像:

<html manifest="calendar.cache">
  <head>
    <script src="scripts/jquery.js" type="text/javascript"></script>
    <script src="scripts/calendar.js" type="text/javascript"></script>
    <script src='https://apis.google.com/js/client.js?onload=checkAuth'></script>
  </head>
  <body>
    <div id="authorize-div" style="display: inline">
      <span>Authorize access to Google Calendar API</span>
      <!--Button for the user to click to initiate auth sequence -->
      <button id="authorize-button">
        Authorize
      </button>
    </div>
    <pre id="output"></pre>
    <script>

    $(document).ready(function(){

        console.log("ready");
    })
    </script>
  </body>
</html>

如果我禁用缓存一切正常。但是,启用缓存后,apis.google.com/js/client.js 文件出现错误。错误是jquery.js:5 GET https://apis.google.com/js/client.js?onload=checkAuth&amp;_=1474962265124 net::ERR_FAILED。这是针对 google chrome 浏览器的,但我在 firefox 上遇到了类似的错误。我错过了什么?

【问题讨论】:

    标签: javascript jquery html cache-manifest manifest.cache


    【解决方案1】:

    这是由于您为 client.js 传递的参数造成的,即?onload=checkAuth

    在 web 中,只要您传递任何参数,请求就会被认为是唯一的。因此,就浏览器而言,您的清单中声明的​​脚本并不相同

    https://apis.google.com/js/client.js // script A
    https://apis.google.com/js/client.js?onload=checkAuth //script B ≠ script A
    

    但在calendar.cache 中,您仅将脚本 A 声明为非缓存。所以现在您可以猜测将清单更改为下面会解决问题

    CACHE MANIFEST
    calendar.html
    scripts/jquery.js
    scripts/calendar.js
    
    NETWORK:
    https://apis.google.com/js/client.js?onload=checkAuth
    

    Ofc 仅删除 onload=checkAuth 也可以在您不需要回调的情况下工作。只需擦除整个缓存并重新加载即可看到魔力!

    【讨论】:

      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 1970-01-01
      • 2020-05-26
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多