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
79
80
81
82
83
84
85
|
---
title: Large-Allocation
slug: Web/HTTP/Headers/Large-Allocation
translation_of: Web/HTTP/Headers/Large-Allocation
---
<div>{{HTTPSidebar}}</div>
<p>非标准的<strong><code>Large-Allocation</code></strong> 响应头部是用来告诉浏览器加载该页面可能需要申请大内存. 当前只有Firefox实现该特性,但是对其他浏览器也无损害。</p>
<p><a href="/en-US/docs/WebAssembly">WebAssembly</a> 或者 asm.js会使用比较大的连续内存空间。例如, 对于一些复杂的游戏, 其申请的空间将会非常大,甚至会达到1GB。<code>Large-Allocation</code> 告诉浏览器其将要加载的页面可能需要申请一个大的连续内存空间,浏览器依据该头部可能会单独启动一个专有的进程用于处理该页面。</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">Header type</th>
<td>{{Glossary("Response header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
<td>no</td>
</tr>
</tbody>
</table>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">Large-Allocation: 0
Large-Allocation: <megabytes>
</pre>
<h2 id="指令">指令</h2>
<dl>
<dt><code>0</code></dt>
<dd>0 是一个特殊的值,代表给它分配的大小是不确定的(动态允许).</dd>
<dt><code><megabytes></code></dt>
<dd>预期需要申请的内存大小,以M为单位</dd>
<dt></dt>
</dl>
<h2 id="示例">示例</h2>
<pre>Large-Allocation: 0
Large-Allocation: 500
</pre>
<h2 id="排除错误">排除错误</h2>
<p>如果使用不当, <code>Large-Allocation</code> 会抛出警告或者错误信息,你可以在 <a href="/en-US/docs/Tools/Web_Console">web console</a> 查看它们。</p>
<dl>
<dt>由于<code>Large-Allocation报头存在,这个页面会在一个新的进程处理和加载</code></dt>
<dd>This message means that the browser saw the <code>Large-Allocation</code> header, and was able to reload the page into a new process which should have more available contiguous memory.</dd>
<dt> <code>Large-Allocation</code> 报头由于非<code>non-GET请求而直接忽略</code></dt>
<dd>当一个 {{HTTPMethod("POST")}} 请求用语加载文档, that load cannot currently be redirected into a new process. This error is displayed when loading a document with a <code>Large-Allocation</code> header with a non-GET HTTP method. This could be caused due to the document being loaded by a form submission, for example.</dd>
<dt>A <code>Large-Allocation</code> header was ignored due to the presence of windows which have a reference to this browsing context through the frame hierarchy or {{domxref("window.opener")}}.</dt>
<dd>
<p>This error means that the document was not loaded at the top level of an user-opened or noopener-opened tab or window. It can occur in these situations:</p>
<ul>
<li>The document with the <code>Large-Allocation</code> header was loaded in an {{HTMLElement("iframe")}}. Firefox cannot move an iframe into a new process currently, so the document must load in the current process.</li>
<li>The document with the <code>Large-Allocation</code> header was loaded in a window which was opened by {{domxref("window.open()")}}, <code><a target="_blank"></code> or other similar methods without <code>rel="noopener"</code> or the <code>"noopener"</code> feature being set. These windows must remain in the same process as their opener, as they can communicate, meaning that we cannot allow them to switch processes.</li>
<li>The document with the <code>Large-Allocation header</code> has opened another window with {{domxref("window.open()")}}, <code><a target="_blank"></code> or other similar methods without <code>rel="noopener"</code> or the <code>"noopener"</code> feature being set. This is for the same reason as above, namely that they can communicate and thus we cannot allow them to switch processes.</li>
</ul>
</dd>
<dt><code>Large-Allocation</code> 报头由于 文档在加载过程没有被加载而直接忽略</dt>
<dd>Firefox has moved to a <a href="/en-US/docs/Mozilla/Firefox/Multiprocess_Firefox">multiprocess architecture</a>, and this architecture is required in order to support the <code>Large-Allocation</code> header. Some <a href="/en-US/docs/Mozilla/Add-ons/SDK">legacy Addons</a> can prevent Firefox from using this new, faster, multiprocess architecture. If you have one of these Addons installed, then we will continue to use the old single process architecuture for compatibility, and cannot handle the <code>Large-Allocation</code> header.</dd>
<dt>由于<code>Large-Allocation</code>头部,此页面应将被加载到新进程中, 但是在非Win32平台上禁用此选项。</dt>
<dd>由于在64位系统里内存碎片不是问题,Firefox只在32位系统支持<code>Large-Allocation</code>头部。如果你运行一个非32位的程序,这类信息就会出现。可以设置about:config里面的"dom.largeAllocation.forceEnable"布尔值来关闭此检查。</dd>
<dd></dd>
</dl>
<h2 id="规范">规范</h2>
<p>现还不属于任何规范,可以通过<a href="https://gist.github.com/mystor/5739e222e398efc6c29108be55eb6fe3">这篇文档</a>了解该头部的背后思想。</p>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("http.headers.Large-Allocation")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li><a href="/en-US/docs/WebAssembly">WebAssembly</a></li>
</ul>
|