Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. Speculation-Rules

Speculation-Rules header

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

The HTTPSpeculation-Rulesresponse header provides one or more URLs pointing to text resources containing speculation rule JSON definitions. When the response is an HTML document, these rules will be added to the document's speculation rule set. See theSpeculation Rules API for more information.

The resource file containing the speculation rules JSON can have any valid name and extension, but it will be requested with adestination type ofspeculationrules, and must be served with anapplication/speculationrules+json MIME type.

Note:This mechanism provides an alternative to specifying the JSON definition inside an inline<script type="speculationrules"> element. Specifying an HTTP header is useful in cases where developers are not able to directly modify the document itself.

Header typeResponse header

Syntax

http
Speculation-Rules: <url-list>

Directives

<url-list>

A comma-separated list of URLs pointing to text resources containing speculation rule JSON definitions. The JSON contained in the text files must follow the same rules as that contained inside inline<script type="speculationrules"> elements. SeeSpeculation rules JSON representation for the syntax reference.

Examples

Speculation-Rules field with a single file

The following response contains one file reference:

http
Speculation-Rules: "/rules/prefetch.json"

Speculation-Rules field with multiple files

The following response contains multiple file reference as a comma-separated list:

http
Speculation-Rules: "/rules/prefetch.json","/rules/prerender.json"

Note:The URL values must be contained in quotes.

Specifications

Specification
HTML
# the-speculation-rules-header

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp