Skip to content

Conversation

pmeenan
Copy link
Contributor

@pmeenan pmeenan commented Sep 3, 2025

Add processing steps for handling the "compression-dictionary" link relation type defined in HTTP Compression Dictionary Transport.

It largely mirrors the support for prefetch but also adds a default crossorigin mode of "cors" anonymous (necessary for dictionaries to be usable in a third-party context).

Fix #11619


/index.html ( diff )
/links.html ( diff )
/references.html ( diff )
/semantics.html ( diff )

@pmeenan
Copy link
Contributor Author

pmeenan commented Sep 3, 2025

RFC is pending publication so this should wait until it has been published (any day now - final edits are complete).

<li><p>If the state of <var>el</var>'s <code data-x="attr-link-crossorigin">crossorigin</code>
content attribute is not set, set <var>options</var>'s
<span data-x="link options crossorigin">crossorigin</span> to
<span data-x="attr-crossorigin-anonymous">Anonymous</span>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #11619 (comment): this step will never execute, as per https://html.spec.whatwg.org/#cors-settings-attribute the attribute always has a state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I changed it to check to see if crossorigin was "No CORS" and change it to Anonymous. Another way to word it that matches the original text would be to reference the original creation of "el", something like If, when the element is created, the crossorigin attribute is not set...

source Outdated
</ol>

<p>The <span>process a link header</span> steps for this type of linked resource are to do
nothing.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checking that this is intended? https://datatracker.ietf.org/doc/draft-ietf-httpbis-compression-dictionary/ seems to imply the Link: header should work, but this mandates that in browsers it do nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Mistake from mirroring the prefetch behavior. Should be fixed now. The flow feels a bit weird since I merged the header and link element processing steps but need to not fire the load/error in the header side of things (made el optional to the processing). Happy for suggestions on ways to make it cleaner.

Presumably we could also treat it more like preconnect and fire-and-forget without load/error events.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intended pattern is supposed to be like what preload does. I believe you could make that work, but I haven't double-checked...

@domenic
Copy link
Member

domenic commented Sep 4, 2025

The structure here is a bit surprising for me, in that you have HTML just do a fetch, and then do nothing with the response.

Instead, you seem to have located the response processing all in whatwg/fetch#1854. I can understand that if the goal is that there are many places that should be able to trigger that processing, e.g., if you want to be able to trigger it from fetch(). But, if HTML is the only place on the web platform that can set a "compression-dictionary" initiator, what is the point of that?

A more normal processing model would be to process the response in HTML, and not modify Fetch much. Was that considered?

@pmeenan
Copy link
Contributor Author

pmeenan commented Sep 4, 2025

The structure here is a bit surprising for me, in that you have HTML just do a fetch, and then do nothing with the response.

Instead, you seem to have located the response processing all in whatwg/fetch#1854. I can understand that if the goal is that there are many places that should be able to trigger that processing, e.g., if you want to be able to trigger it from fetch(). But, if HTML is the only place on the web platform that can set a "compression-dictionary" initiator, what is the point of that?

A more normal processing model would be to process the response in HTML, and not modify Fetch much. Was that considered?

Compression dictionaries are a transport-layer content-encoding and entirely handled within fetch. For the most part they should be completely transparent to HTML. Any HTTP response for any fetch can be stored as a compression dictionary and, usually, none of that will even be visible from HTML.

We did need a way to trigger a fetch for triggering the request of a dictionary that would not have otherwise been loaded (which will then be treated like any other response and handled entirely at the HTTP layer). preload and prefetch both would have worked fine (and can still work if someone uses them and they have the appropriate response headers) but by using a dedicated relation type we can avoid triggering fetches from clients that don't support compression dictionaries.

It also allows for adjusting the priorities and timing of the fetch independently from prefetches and preloads.

@domenic
Copy link
Member

domenic commented Sep 8, 2025

Any HTTP response for any fetch can be stored as a compression dictionary and, usually, none of that will even be visible from HTML.

Got it. I misunderstood the role of the compression-dictionary initiator. It is not required that the request initiator be set to compression-dictionary, for the response to be used as such.

In that case, I agree with the design split.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support for <link rel=compression-dictionary ...>
2 participants