这是indexloc提供的服务,不要输入任何密码

Speculation Rules

Draft Community Group Report,

This version:
https://wicg.github.io/nav-speculation/speculation-rules.html
Issue Tracking:
GitHub
Editors:
(Google)
(Google)

Abstract

Extensions to speculation rules to support navigational prerendering.

Status of this document

This specification was published by the Web Platform Incubator Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

1. This specification is moving to HTML

The majority of this specification is being upstreamed to the HTML Standard: see whatwg/html#11426 and whatwg/html#11123. The rendered specification text can currently be found at this PR preview.

What remains in this document are some additional patches to support prerendering, which the upstreamed version does not yet cover. Once prefetch is also upstreamed, what remains in this document will likely migrate to [PRERENDERING-REVAMPED].

2. Parsing

Extend the speculation rule set struct with one additional item:

Extend the speculation rule struct with one additional item:

Modify parse a speculation rule set string as follows:

Implementations will still be allowed to treat prerender candidates as prefetches, per the modifications in § 3 Processing model.

Modify parse a speculation rule by adding the following steps:
  1. Let targetHint be null.

  2. If input["target_hint"] exists:

    1. If input["target_hint"] is not a valid navigable target name or keyword:

      1. The user agent may report a warning to the console indicating that the supplied target hint was invalid.

      2. Return null.

    2. Set targetHint to input["target_hint"].

and then updating the final step which returns a speculation rule to include setting the target navigable name hint to targetHint.

3. Processing model

A prerender candidate is a speculative load candidate with the following additional item:

Update the inner consider speculative loads steps algorithm by appending the following steps near the beginning, after assembling prefetchCandidates:
  1. Let prerenderCandidates be an empty list.

  2. For each ruleSet of document’s speculation rule sets:

    1. For each rule of ruleSet’s prerender rules:

      1. For each url of rule’s URLs:

        1. Let referrerPolicy be the result of computing a speculative load referrer policy given rule and null.

        2. Append a new prerender candidate with

          URL

          url

          No-Vary-Search hint

          rule’s No-Vary-Search hint

          eagerness

          rule’s eagerness

          referrer policy

          referrerPolicy

          tags

          rule’s tags

          target navigable name hint

          rule’s target navigable name hint

          to prerenderCandidates.

      2. If rule’s predicate is not null, then:

        1. Let links be the result of finding matching links given document and rule’s predicate.

        2. For each link of links:

          1. Let target be rule’s target navigable name hint.

          2. If target is null, set it to the result of getting an element’s target given link.

          3. Let referrerPolicy be the result of computing a speculative load referrer policy given rule and link.

          4. Append a prerender candidate with

            URL

            link’s url

            No-Vary-Search hint

            rule’s No-Vary-Search hint

            eagerness

            rule’s eagerness

            referrer policy

            referrerPolicy

            tags

            rule’s tags

            target navigable name hint

            target

            to prerenderCandidates.

  3. Let speculativeLoadCandidates be the union of prefetchCandidates and prerenderCandidates.

Update subsequent steps for canceling not-still-being-speculated prefetch records to operate on speculativeLoadCandidates instead of prefetchCandidates.

Replace the step which performs the actual prefetching by looping over prefetchCandidates with the following:

  1. For each candidate of speculativeLoadCandidates:

    1. The user agent may run the following steps:

      1. Let tagCandidates be speculativeLoadCandidates.

      2. If candidate is a prerender candidate, then set tagCandidates to prerenderCandidates.

      3. Let tagsToSend be the result of collecting tags for matching speculative load candidates given candidate and tagCandidates.

      4. Let prefetchRecord be a new prefetch record with

        source

        "speculation rules"

        URL

        candidate’s URL

        No-Vary-Search hint

        candidate’s No-Vary-Search hint

        referrer policy

        candidate’s referrer policy

        tags

        tagsToSend

      5. If candidate is a prefetch candidate, then set prefetchRecord’s anonymization policy to candidate’s anonymization policy.

      6. If candidate is a prerender candidate, then the user agent may run the following steps:

        1. Set prefetchRecord’s prerendering traversable to "to be created"

        2. Set prefetchRecord’s prerendering target navigable name hint to candidate’s target navigable name hint.

        3. Start a referrer-initiated navigational prerender given document and prefetchRecord.

      7. If the user agent did not run the previous step, then start a referrer-initiated navigational prefetch given document and prefetchRecord.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CONSOLE]
Dominic Farolino; Robert Kowalski; Terin Stock. Console Standard. Living Standard. URL: https://console.spec.whatwg.org/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[PREFETCH]
Prefetch. Draft Community Group Report. URL: https://wicg.github.io/nav-speculation/prefetch.html
[PRERENDERING-REVAMPED]
Prerendering Revamped. Draft Community Group Report. URL: https://wicg.github.io/nav-speculation/prerendering.html