缓存清单在使用跨域引用和 SSL 的 safari 中不起作用
Cache manifest not working in safari using cross-domain refs and SSL
我一直在尝试让我的 HTML5 离线缓存清单在使用 HTTPS 访问网站时在 Safari 中正常工作。
我有以下设置:
index.html:
<!doctype html>
<html lang="en" dir="ltr" manifest="app.appcache">
<head>
<base href="https://www.example.com">
<link rel="stylesheet" href="//some.cdn.com/styles.css" charset="utf-8">
<script src="//some.cdn.com/app.js"></script>
</head>
<body>
</body>
</html>
app.appcache
CACHE MANIFEST
//some.cdn.com/styles.css
//some.cdn.com/app.js
NETWORK:
*
通过 HTTP 访问我的站点工作正常!资产被正确加载和缓存;我可以离线使用我的应用程序
在 Chrome 中通过 HTTPS 访问我的网站也可以正常工作
在 Safari 中通过 HTTPS 访问我的网站 中断 :-( 资产正常加载,但不会缓存。调试没有让我进一步。没有有用的信息日志
根据规范,允许在缓存清单中引用另一个域。
我还尝试在我的 HTML 和清单中明确使用 http:// 或 https://,而不是 //-notation。没用。
在我的在线搜索中,我发现了一些关于跨域请求的评论,缓存清单中不允许这样做,但根据 W3C 规范,这是允许的(事实证明浏览器我测试它正确地缓存了所有资产,除了组合 https & safari.
显然我错过了应用缓存的一个重要限制。
如https://www.w3.org/TR/2011/WD-html5-20110525/offline.html所述:
If the manifest's is https: or another scheme intended for encrypted data transfer, then all URLs in explicit sections must have the same origin as the manifest itself.
我一直在尝试让我的 HTML5 离线缓存清单在使用 HTTPS 访问网站时在 Safari 中正常工作。
我有以下设置:
index.html:
<!doctype html>
<html lang="en" dir="ltr" manifest="app.appcache">
<head>
<base href="https://www.example.com">
<link rel="stylesheet" href="//some.cdn.com/styles.css" charset="utf-8">
<script src="//some.cdn.com/app.js"></script>
</head>
<body>
</body>
</html>
app.appcache
CACHE MANIFEST
//some.cdn.com/styles.css
//some.cdn.com/app.js
NETWORK:
*
通过 HTTP 访问我的站点工作正常!资产被正确加载和缓存;我可以离线使用我的应用程序
在 Chrome 中通过 HTTPS 访问我的网站也可以正常工作
在 Safari 中通过 HTTPS 访问我的网站 中断 :-( 资产正常加载,但不会缓存。调试没有让我进一步。没有有用的信息日志
根据规范,允许在缓存清单中引用另一个域。
我还尝试在我的 HTML 和清单中明确使用 http:// 或 https://,而不是 //-notation。没用。
在我的在线搜索中,我发现了一些关于跨域请求的评论,缓存清单中不允许这样做,但根据 W3C 规范,这是允许的(事实证明浏览器我测试它正确地缓存了所有资产,除了组合 https & safari.
显然我错过了应用缓存的一个重要限制。 如https://www.w3.org/TR/2011/WD-html5-20110525/offline.html所述:
If the manifest's is https: or another scheme intended for encrypted data transfer, then all URLs in explicit sections must have the same origin as the manifest itself.