Device-Memory

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

Device-Memory 是一个跟 Device Memory API 相关的请求头,它跟 Client Hints 请求头的作用相似,用来表示客户端设备内存的近似大小。

Header type Request header
Forbidden header name ?

Note: Client Hints are accessible only on secure origins (via TLS). Server has to opt in to receive Device-Memory header from the client by sending Accept-CH and Accept-CH-Lifetime response headers.

语法

设备的内存大小可能会被用作指纹变量,因此将这个取值设置的比较粗糙,以减少滥用它的可能性。 请求头采用以下值:0.25、0.5、1、2、4、8。

Device-Memory: <number>

示例

服务器需要先发送包含 Device-Memory 的 Accept-CHAccept-CH-Lifetime 响应头,来表明可以接收 Device-Memory 请求头.

Accept-CH: Device-Memory
Accept-CH-Lifetime: 86400

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

Device-Memory: 1

规范

规范 状态 注释
Device Memory 1
Device-Memory
Editor's Draft Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Device-Memory
Experimental
Chrome Full support 61Edge Full support ≤79Firefox ? IE ? Opera Full support 48Safari ? WebView Android Full support 61Chrome Android Full support 61Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android Full support 8.0

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

参见