HTTP Headers
Use As Dictionary
Experimental: This is an experimental technology
Carefully review the Browser compatibility table before implementing this in a production environment.
The HTTP Use-As-Dictionary
response header specifies the matching criteria that the Compression Dictionary Transport dictionary can be used for in subsequent requests.
Refer to the Compression Dictionary Transport guide for detailed information.
Syntax
Use-As-Dictionary: match=""
Use-As-Dictionary: match-dest=("<destination1>" "<destination2>", ...)
Use-As-Dictionary: id="<string-identifier>"
Use-As-Dictionary: type="raw"
Content-Encoding: match="", match-dest=("<destination1>")
Directives
Directives
- match
- A string value containing a URL Pattern: only resources whose URLs match this pattern may use this resource as a dictionary.
- match-dest
- A space-separated list of strings, with each string in quotes and the whole value enclosed in parentheses, that provides a list of Fetch 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.
Example
Examples
This set of examples describes how to specify and use dictionaries in URL matching scenarios. Each example demonstrates different features such as path prefix matching, versioned directories, resource destination filtering, identification tokens, and data types for dictionaries, providing a comprehensive overview of configuration options.
Path prefix
Use-As-Dictionary: match="/product/*"
This configuration indicates that the dictionary should be used only for URLs that start with /product/
. It ensures targeted application of dictionary rules, optimizing resource matching and management.
Versioned directories
Use-As-Dictionary: match="/app/*/main.js"
This setup employs a wildcard to match multiple versions or variations of a specific file, such as different cache-busted or environment-specific scripts.
Destinations
Use-As-Dictionary: match="/product/*", match-dest=("document")
Here, the match-dest
parameter limits the dictionary application to requests for document resources only, excluding resource types like scripts or styles. For example, a script request such as <script src="/product/js/app.js">
would be omitted from matching.
Use-As-Dictionary: match="/product/*", match-dest=("document" "frame")
This configuration expands matching to include both top-level documents and iframe resources, providing flexible resource categorization for dictionary use.
Id
Use-As-Dictionary: match="/product/*", id="dictionary-12345"
Including an id
in the Use-As-Dictionary
directive embeds a unique identifier into the Dictionary-ID request header. Additionally, resource requests will carry the SHA-256 hash of the dictionary enclosed in colons within the Available-Dictionary header, facilitating verification and cache validation.
Accept-Encoding: gzip, br, zstd, dcb, dcz
Available-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
Dictionary-ID: "dictionary-12345"
The server must authenticate the dictionary by verifying the hash provided in the Available-Dictionary
header. The Dictionary-ID
helps the server identify the specific dictionary associated with the request but does not replace hash verification for integrity.
Type
Use-As-Dictionary: match="/product/*", type="raw"
Currently, only raw
is supported as the dictionary type, which is also the default setting. This configuration mainly serves as a placeholder for potential future enhancements that might support other data formats.
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Use As Dictionary header. This can help you test and debug applications that depend on specific header values by simulating different scenarios easily. Steps to Modify the Use As Dictionary Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Use As Dictionary.
- In the “Header Value” field, enter your desired value for the dictionary usage.
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Modifying the Use As Dictionary header allows you to test how your server or application behaves when interpreting incoming data as dictionaries. This is useful for debugging or ensuring compatibility with different client requests.
Table of Contents
- No headings found.