缓存清单:什么是首选在线设置? [英] Cache Manifest: What is the prefer-online setting?

查看:110
本文介绍了缓存清单:什么是首选在线设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种缓存页面的方式,只有在用户离线时才能使用,否则通常会下载页面。但是,一旦检测到缓存清单,浏览器将只从这些缓存页面加载。



我的搜索使我着迷于 http://whatwg.org 。关于编写缓存清单引起了我的注意。以下是摘录:


分节标题

节标题更改当前节。有四种可能的节标题:

  CACHE:
切换到显式部分。
FALLBACK:
切换到后备部分。
网络:
切换到在线白名单部分。
设置:
切换到设置部分。


前三个是众所周知的,但我没有听说过最后一节标题 SETTINGS:。文档继续说道:


目前只定义了一个设置

缓存模式设置



这包括字符串 prefer-online 。它将缓存模式设置为prefer-online。 (缓存模式默认为快速。)


这让我怀疑 prefer-online 设置正是我所期待的。我希望这个设置能告诉浏览器,如果设置设置为 fast ,它应该只加载缓存页面,否则,如果用户在线,请下载页面。 / p>

不幸的是,我找不到任何关于此的附加信息或解释。有没有人遇到有关 prefer-online 设置的任何信息?或者关于 SETTINGS:部分一般?

解决方案

<$ c如果存在连接,$ c> prefer-online 将转到服务器,即使文件被缓存。如果没有连接,它将使用缓存。



fast 将使用脱机版本,即使存在一个连接。

虽然您可以设置这些偏好,但用户代理仍然可以决定它认为最好的方式。


I've been looking for a way to cache pages for use only when the user is offline, otherwise download the pages normally. However, once a cache manifest is detected, the browser will only load from those cached pages.

My search landed me on http://whatwg.org. The section about Writing Cache Manifests caught my eye. Here's an excerpt:

A section header

Section headers change the current section. There are four possible section headers:

CACHE:
    Switches to the explicit section. 
FALLBACK:
    Switches to the fallback section. 
NETWORK:
    Switches to the online whitelist section. 
SETTINGS:
    Switches to the settings section.

The first three are well known, but I hadn't heard of the last section header, SETTINGS:. The documentation continues to say this:

Currently only one setting is defined:

The cache mode setting

This consists of the string "prefer-online". It sets the cache mode to prefer-online. (The cache mode defaults to fast.)

This made me wonder if the prefer-online setting was exactly what I was looking for. I was hoping that this setting would tell the browser that it should only load the cached pages if the setting was set to fast, otherwise download the pages if the user is online.

Unfortunately, I can't find any additional information or explanation about this. Has anyone come across any information about the prefer-online setting? Or about the SETTINGS: section in general?

解决方案

prefer-online will go to the server if there is a connection, even if the file is cached. If there is no connection it will use the cache.

fast will use the offline version, even if there is a connection.

Although you can set these preferences, the user agent can still decide what it thinks is best.

这篇关于缓存清单:什么是首选在线设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆