blob: d7a74581a2e4359921f8a21a37aa343c747c81a5 (
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
|
---
title: DPR
slug: Web/HTTP/Headers/DPR
translation_of: Web/HTTP/Headers/DPR
---
<div>{{HTTPSidebar}}{{securecontext_header}}{{SeeCompatTable}}</div>
<p><code><strong>DPR</strong></code>请求头是<font><font>“ </font></font><font><font><a href="/zh-CN/docs/Glossary/Client_hints">客户端提示”</a>消息头,它代表客户端设备的像素比</font></font>({{Glossary("DPR")}})<font><font>,该比例是与每个CSS像素相对应的物理设备像素的数量。</font></font></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>DPR</code> header from the client by sending {{HTTPHeader("Accept-CH")}} and {{HTTPHeader("Accept-CH-Lifetime")}} response headers.</p>
</div>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">DPR: <number>
</pre>
<h2 id="示例">示例</h2>
<p>Server first needs to opt in to receive <code>DPR</code> header by sending the response headers {{HTTPHeader("Accept-CH")}} containing <code>DPR</code> and {{HTTPHeader("Accept-CH-Lifetime")}}.</p>
<pre>Accept-CH: DPR
Accept-CH-Lifetime: 86400
</pre>
<p>Then on subsequent requests the client might send <code>DPR</code> header back:</p>
<pre>DPR: 1.0
</pre>
<h2 id="浏览器兼容">浏览器兼容</h2>
<p>{{Compat("http.headers.DPR")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li>{{HTTPHeader("Accept-CH")}}</li>
<li>{{HTTPHeader("Accept-CH-Lifetime")}}</li>
<li>{{HTTPHeader("Vary")}}</li>
</ul>
|