demo · v130
Use-as-Dictionary header builder
Construct the Use-As-Dictionary response header that promotes a resource into the browser's dictionary cache. Tweak match (URL pattern), match-dest, type, ttl; then probe several future request URLs and request-destinations to see which would pick this dictionary up.
dictionary properties
URL pattern (UrlPattern syntax)
match-dest
leave empty for "any"
spec currently only defines "raw"
dictionary is dropped after this many seconds
generated response headers
match probe
would these future requests pick this dictionary up?
the code
// Express / Hono / Workers etc.
res.headers.set("Use-As-Dictionary",
'match="/static/app-*", match-dest=("script"), type="raw", id="app-v3-base"');
res.headers.set("Cache-Control", "max-age=2592000");
// Subsequent matching requests will carry:
// Available-Dictionary: :sha256-of-the-dictionary-bytes:
// Sec-Available-Dictionary: app-v3-base
// Server may then respond with Content-Encoding: dcb (or dcz).