Device-Memory

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

Device-Memory 设备客户端提示请求标头的字段指示客户端设备上可用内存的近似大小。该标头属于设备内存 API

标头类型 请求标头客户端提示
禁止修改的标头

备注:

  • 客户端提示仅在安全来源(通过 TLS)上可用。
  • 服务器必须通过发送 Accept-CH 响应标头,才能接收来自客户端的 Device-Memory 标头。
  • 选择加入 Device-Memory 客户端提示的服务器通常也会在 Vary 标头中指定它。这会通知缓存服务器:服务器可能会根据请求中的标头值发送不同的响应。

语法

http
Device-Memory: <number>

指令

<number>

设备内存的近似大小。可能的值有:0.250.51248

设备内存的大小可被用作指纹识别的变量,因此标头的值故意设置得很粗略,以减小其被滥用的可能性。

示例

服务器需要先发送包含 Device-MemoryAccept-CH 响应标头,来选择接收 Device-Memory 请求标头。

http
Accept-CH: Device-Memory

接下来客户端发送的请求则可能会包含 Device-Memory 请求头:

http
Device-Memory: 1

规范

Specification
Device Memory
# iana-device-memory

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Device-Memory request header

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

参见