我的缓存清单文件如下所示:
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&_=1474962265124 net::ERR_FAILED
。这是针对谷歌chrome浏览器的,但我在firefox上遇到了类似的错误。我遗漏了什么?
发布于 2016-09-28 12:54:25
这是由于您为client.js (即?onload=checkAuth
)传递的那些参数造成的。
在web中,只要传递任何参数,就浏览器而言,请求就被认为是unique.So。在清单中声明脚本是不同的
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声明为非缓存。因此,现在您可以猜测,将manifest更改为下面的值可以解决此问题
CACHE MANIFEST
calendar.html
scripts/jquery.js
scripts/calendar.js
NETWORK:
https://apis.google.com/js/client.js?onload=checkAuth
如果你不需要callback.Just擦除整个缓存并重新加载就可以看到神奇的效果,那么只需删除onload=checkAuth
也可以!
https://stackoverflow.com/questions/39731883
复制相似问题