1

I'm trying to build a simple single HTML page that can be launched when offline (on Android, if that matters).

I'm using the Web App Manifest to give the app a name for adding to the home screen and display fullscreen with no browser chrome. This much works.

<!DOCTYPE html>
<html>
<head>
<link rel="manifest" href="mf.webmanifest">
<meta name="mobile-web-app-capable" content="yes">
</head>
...
</html>

This does not appear to be cached when offline. Separately, I can make a page which is cached offline using the application cache:

<!DOCTYPE html>
<html manifest="mf.appcache">
<head>
<meta name="mobile-web-app-capable" content="yes">
</head>
...
</html>

However, when I try to combine these two (so I can have an offline-cached page that launches fullscreen), the Web App Manifest is ignored and I only get the offline behaviour as in the second example.

What I ultimately want is a single page that can be added to the home screen, that opens full screen with no browser/OS chrome at all, and is cached for use offline. A solution that works just on Android using Chrome 65 is acceptable.

4

2 回答 2

1

这是一个有趣的困境!我想知道您是否会 <link rel="manifest" href="/manifest.json">按照 Google 的描述使用更好的运气。这是他们对Web App Manifest 的建议的链接。

Web App Capable 元标记主要用于全屏功能。如果您特别想要缓存,我认为使用http-equiv="cache-control"标头标记及其指令更接近您想要完成的任务。特别是因为服务工作者还没有得到全球支持。我在堆栈上找到了关于 HTML 缓存的一个不错的解释:“如何为缓存控制设置 HTTP 标头”。

编辑:另一位用户指出,如果在清单文件中设置了显示,Chrome 将不会遵守此标签

于 2018-04-18T05:35:36.003 回答
0

Service Workers功能提供与已弃用的应用程序缓存相同的功能。

MDN 有一篇关于使用 Service Worker 的文章,我发现它对实现替换应用程序缓存所需的内容非常有帮助。

于 2018-04-23T09:23:45.843 回答