Use-As-Dictionary header
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
The HTTPUse-As-Dictionary
response header lists the matching criteria that theCompression Dictionary Transport dictionary can be used for, for future requests.
See theCompression Dictionary Transport guide for more information.
In this article
Syntax
Use-As-Dictionary: match="<url-pattern>"Use-As-Dictionary: match-dest=("<destination1>" "<destination2>", …)Use-As-Dictionary:Use-As-Dictionary: type="raw"// Multiple, in any orderContent-Encoding: match="<url-pattern>", match-dest=("<destination1>")
Directives
match
A string value containing aURL Pattern: only resources whose URLs match this pattern may use this resource as a dictionary. Regular expression capturing groups are not allowed, so
URLPattern.hasRegExpGroups
must befalse
.match-dest
A space-separated list of strings, with each string in quotes and the whole value enclosed in parentheses, that provides a list ofFetch request destinations that requests must match if they are to use this dictionary.
id
A string value that specifies a server identifier for the dictionary. This ID value will then be added in the
Dictionary-ID
request header when the browser requests a resource which can use this dictionary.type
A string value that describes the file format of the supplied dictionary. Currently only
raw
is supported (which is the default) so this is more for future compatibility.
Examples
>Path prefix
Use-As-Dictionary: match="/product/*"
This says the dictionary is only to be used for URLs starting with/product/
.
Versioned directories
Use-As-Dictionary: match="/app/*/main.js"
This uses a wildcard to match multiple versions of a file.
Destinations
Use-As-Dictionary: match="/product/*", match-dest=("document")
This usesmatch-dest
to ensure the dictionary is only used fordocument
requests so<script src="/product/js/app.js">
resource requests for example would not match.
Use-As-Dictionary: match="/product/*", match-dest=("document" "frame")
This would allow the dictionary to match both top-level documents and iframes.
Id
Use-As-Dictionary: match="/product/*",
WhenUse-As-Dictionary
includes anid
directive, as in this example, theid
value will be included in theDictionary-ID
request header for resources that can use this dictionary. The resource request will also include the SHA-256 hash of the dictionary surrounded by colons in theAvailable-Dictionary
header:
Accept-Encoding: gzip, br, zstd, dcb, dczAvailable-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:Dictionary-ID: "dictionary-12345"
The server must still check the hash from theAvailable-Dictionary
header — theDictionary-ID
is additional information for the server to identify the dictionary but does not replace the need for theAvailable-Dictionary
header.
Type
Use-As-Dictionary: match="/product/*", type="raw"
Currently, onlyraw
is supported (which is the default) so this is more for future compatibility.
Specifications
Specification |
---|
Compression Dictionary Transport> # name-use-as-dictionary> |
Browser compatibility
Loading…