语法
http
Use-As-Dictionary: match="<url-pattern>"
Use-As-Dictionary: match-dest=("<destination1>" "<destination2>", …)
Use-As-Dictionary: id="<string-identifier>"
Use-As-Dictionary: type="raw"
// Multiple, in any order
Content-Encoding: match="<url-pattern>", match-dest=("<destination1>")
指令
match
-
一个字符串值,包含一个URL 模式:只有 URL 与此模式匹配的资源才能使用此资源作为字典。不允许使用正则表达式捕获组,因此
URLPattern.hasRegExpGroups
必须为false
。 match-dest
-
一个以空格分隔的字符串列表,每个字符串用引号引起来,整个值括在括号中,提供了一个Fetch 请求目标列表,如果请求要使用此字典,则必须匹配这些目标。
id
-
一个字符串值,为字典指定服务器标识符。当浏览器请求可以使用此字典的资源时,此 ID 值将添加到
Dictionary-ID
请求头中。 type
-
一个字符串值,描述所提供字典的文件格式。目前只支持
raw
(默认值),因此这更多是为了未来兼容性。
示例
路径前缀
http
Use-As-Dictionary: match="/product/*"
这表示字典只能用于以/product/
开头的 URL。
版本化目录
http
Use-As-Dictionary: match="/app/*/main.js"
这使用通配符来匹配文件的多个版本。
目标
http
Use-As-Dictionary: match="/product/*", match-dest=("document")
这使用match-dest
来确保字典仅用于document
请求,因此例如<script src="/product/js/app.js">
资源请求将不匹配。
http
Use-As-Dictionary: match="/product/*", match-dest=("document" "frame")
这将允许字典匹配顶级文档和 iframe。
Id
http
Use-As-Dictionary: match="/product/*", id="dictionary-12345"
当Use-As-Dictionary
包含id
指令时(如本例所示),id
值将包含在可使用此字典的资源的Dictionary-ID
请求头中。资源请求还将包含由冒号包围的字典的 SHA-256 哈希值,位于Available-Dictionary
头中。
http
Accept-Encoding: gzip, br, zstd, dcb, dcz
Available-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
Dictionary-ID: "dictionary-12345"
服务器仍然必须检查来自Available-Dictionary
头的哈希值——Dictionary-ID
是服务器识别字典的附加信息,但不能替代对Available-Dictionary
头的需求。
类型
http
Use-As-Dictionary: match="/product/*", type="raw"
目前,只支持raw
(默认值),因此这更多是为了未来兼容性。
规范
规范 |
---|
压缩字典传输 # name-use-as-dictionary |
浏览器兼容性
加载中…