Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -15557,6 +15557,7 @@ interface <dfn interface>HTMLLinkElement</dfn> : <span>HTMLElement</span> {
the processing model, and are supported by the user agent. The possible <span
data-x="concept-supported-tokens">supported tokens</span> are
<code data-x="rel-alternate">alternate</code>,
<code data-x="rel-compression-dictionary">compression-dictionary</code>,
<code data-x="rel-dns-prefetch">dns-prefetch</code>,
<code data-x="rel-expect">expect</code>,
<code data-x="rel-icon">icon</code>,
Expand Down Expand Up @@ -26186,6 +26187,7 @@ document.body.appendChild(wbr);</code></pre>

<p>Keywords that are <dfn>body-ok</dfn> affect whether <code>link</code> elements are
<span>allowed in the body</span>. The <span>body-ok</span> keywords are
<code data-x="rel-compression-dictionary">compression-dictionary</code>,
<code data-x="rel-dns-prefetch">dns-prefetch</code>,
<code data-x="rel-modulepreload">modulepreload</code>,
<code data-x="rel-pingback">pingback</code>,
Expand Down Expand Up @@ -26251,6 +26253,17 @@ document.body.appendChild(wbr);</code></pre>
<td>Gives the permalink for the nearest ancestor section.</td>
</tr>

<tr>
<td><code data-x="rel-compression-dictionary">compression-dictionary</code></td>
<td><span data-x="external resource link">External Resource</span></td>
<td colspan="2"><em>not allowed</em></td>
<td class="yes"> Yes </td>
<td class="yes"> Yes </td>
<td>Specifies that the user agent should preemptively <span data-x="concept-fetch">fetch</span> and cache the
target resource as it is likely to be useful as a compression dictionary for future
<span data-x="concept-fetch">fetches</span>. <ref>RFC9842</ref></td>
</tr>

<tr>
<td><code data-x="rel-dns-prefetch">dns-prefetch</code></td>
<td><span data-x="external resource link">External Resource</span></td>
Expand Down Expand Up @@ -26672,6 +26685,93 @@ document.body.appendChild(wbr);</code></pre>
Link Relation</cite>. <ref>RFC6596</ref></p>


<h5>Link type "<dfn attr-value for="link/rel"><code
data-x="rel-compression-dictionary">compression-dictionary</code></dfn>"</h5>

<p>The <code data-x="rel-compression-dictionary">compression-dictionary</code> keyword may be used
with <code>link</code> elements. This keyword creates an <span data-x="external resource link">external
resource link</span>. This keyword is <span>body-ok</span>.</p>

<p>The <code data-x="rel-compression-dictionary">compression-dictionary</code> keyword indicates
that preemptively <span data-x="concept-fetch">fetching</span> and caching the specified resource
or same-site document is likely to be beneficial, as it is highly likely that the user will
be able to this resource as a compression dictionary for future
<span data-x="concept-fetch">fetches</span>. <ref>RFC9842</ref></p>

<p>There is no default type for resources given by the
<code data-x="rel-compression-dictionary">compression-dictionary</code> keyword.</p>

<p>The appropriate times to <span data-x="fetch and process the linked resource">fetch and
process</span> this type of link are:</p>

<ul>
<li><p>When the <span>external resource link</span> is created on a <code>link</code> element
that is already <span>browsing-context connected</span>.</p></li>

<li><p>When the <span>external resource link</span>'s <code>link</code> element <span>becomes
browsing-context connected</span>.</p></li>

<li><p>When the <code data-x="attr-link-href">href</code> attribute of the <code>link</code>
element of an <span>external resource link</span> that is already <span>browsing-context
connected</span> is changed.</p></li>

<li><p>When the <code data-x="attr-link-crossorigin">crossorigin</code> attribute of the
<code>link</code> element of an <span data-x="external resource link">external resource
link</span> that is already <span>browsing-context connected</span> is set, changed, or
removed.</p></li>
</ul>

<p>The <span>fetch and process the linked resource</span> steps for this type of linked resource,
given a <code>link</code> element <var>el</var>, are to <span
data-x="create link options from element">create link options</span> from <var>el</var> and
to <span>load a compression dictionary</span> given the result and <var>el</var>.</p>

<p>The <span>process a link header</span> step for this type of linked resource given a <span
data-x="link processing options">link processing options</span> <var>options</var> are to
<span>load a compression dictionary</span> given <var>options</var>.</p>

<p>To <dfn>load a compression dictionary</dfn> given a <span>link processing options</span>
<var>options</var> and optional <code>link</code> element <var>el</var>:</p>

<ol>
<li><p>If <var>options</var>'s <span data-x="link options crossorigin">crossorigin</span>
is <span data-x="attr-crossorigin-none">No CORS</span>, set <var>options</var>'s
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...

<span data-x="link options crossorigin">crossorigin</span> to
<span data-x="attr-crossorigin-anonymous">Anonymous</span>.</p></li>

<li><p>Set <var>options</var>'s <span data-x="link options destination">destination</span> to
the empty string.</p></li>

<li><p>Let <var>request</var> be the result of <span data-x="create a link request">creating a
link request</span> given <var>options</var>.</p></li>

<li><p>If <var>request</var> is null, then return.</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-initiator">initiator</span> to
"<code data-x="">compression-dictionary</code>".</p></li>

<li>
<p>Let <var>processCompressionDictionaryResponse</var> be the following steps given a <span
data-x="concept-response">response</span> <var>response</var> and null, failure, or a
<span>byte sequence</span> <var>bytesOrNull</var>:</p>

<ol>
<li><p>If <var>response</var> is a <span>network error</span> and <var>el</var> is set, <span
data-x="concept-event-fire">fire an event</span> named <code
data-x="event-error">error</code> at <var>el</var>.</p></li>

<li><p>Otherwise, if <var>el</var> is set, <span data-x="concept-event-fire">fire an event</span>
named <code data-x="event-load">load</code> at <var>el</var>.</p></li>
</ol>
</li>

<li><p>The user agent should <span data-x="concept-fetch">fetch</span> <var>request</var>, with
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> set to
<var>processCompressionDictionaryResponse</var>. User agents may delay the fetching of
<var>request</var> to prioritize other requests that are necessary for the current document.</p></li>
</ol>

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...


<h5>Link type "<dfn attr-value for="link/rel"><code
data-x="rel-dns-prefetch">dns-prefetch</code></dfn>"</h5>

Expand Down Expand Up @@ -147865,6 +147965,9 @@ INSERT INTERFACES HERE
<dt id="refsRFC8297">[RFC8297]</dt>
<dd><cite><a href="https://httpwg.org/specs/rfc8297.html">An HTTP Status Code for Indicating Hints</a></cite>, K. Oku. IETF.</dd>

<dt id="refsRFC9842">[RFC9842]</dt>
<dd><cite><a href="https://www.rfc-editor.org/rfc/rfc9842">Compression Dictionary Transport</a></cite>, P. Meenan, Y. Weiss. IETF.</dd>

<dt id="refsSCREENORIENTATION">[SCREENORIENTATION]</dt>
<dd><cite><a href="https://w3c.github.io/screen-orientation/">Screen Orientation</a></cite>, M. Cáceres. W3C.</dd>

Expand Down