aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/device-memory/index.html
blob: dbc49f5b0ae572a91bde26b9dd6370f14327f943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
title: Device-Memory
slug: Web/HTTP/Headers/Device-Memory
translation_of: Web/HTTP/Headers/Device-Memory
---
<div>{{HTTPSidebar}}{{securecontext_header}}{{SeeCompatTable}}</div>

<p><code><strong>Device-Memory</strong></code> 是一个跟 <a href="/en-US/docs/Web/API/Device_Memory_API">Device Memory API</a> 相关的请求头,它跟 <a href="/en-US/docs/Glossary/Client_hints">Client Hints</a> 请求头的作用相似,用来表示客户端设备内存的近似大小。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>?</td>
  </tr>
 </tbody>
</table>

<div class="blockIndicator note">
<p><strong>Note:</strong> Client Hints are accessible only on secure origins (via TLS). Server has to opt in to receive <code>Device-Memory</code> header from the client by sending {{HTTPHeader("Accept-CH")}} and {{HTTPHeader("Accept-CH-Lifetime")}} response headers.</p>
</div>

<h2 id="语法">语法</h2>

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

<pre class="syntaxbox">Device-Memory: &lt;number&gt;
</pre>

<h2 id="示例">示例</h2>

<p>服务器需要先发送包含 <code>Device-Memory</code> 的 {{HTTPHeader("Accept-CH")}}{{HTTPHeader("Accept-CH-Lifetime")}} 响应头,来表明可以接收 <code>Device-Memory</code> 请求头.</p>

<pre>Accept-CH: Device-Memory
Accept-CH-Lifetime: 86400
</pre>

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

<pre>Device-Memory: 1
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
  <tr>
   <td>{{SpecName("Device Memory","#sec-device-memory-client-hint-header","Device-Memory")}}</td>
   <td>{{Spec2('Device Memory')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{Compat("http.headers.Device-Memory")}}</p>

<h2 id="参见">参见</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/Device_Memory_API">Device Memory API</a></li>
 <li>{{HTTPHeader("Accept-CH")}}</li>
 <li>{{HTTPHeader("Accept-CH-Lifetime")}}</li>
 <li>{{HTTPHeader("Vary")}}</li>
 <li>{{DOMxRef("Navigator.deviceMemory")}}</li>
</ul>