CSP: prefetch-src

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

HTTP の Content-Security-Policy (CSP) における prefetch-src ディレクティブは、事前読み込みまたは事前描画することができる有効なリソースを指定します。

CSP バージョン 3
ディレクティブ種別 フェッチディレクティブ
default-src による代替 あり。このディレクティブがない場合、ユーザーエージェントは default-src ディレクティブを探します。

構文

prefetch-src ポリシーには、 1 つ以上のソースが許可されています。

http
Content-Security-Policy: prefetch-src <source>;
Content-Security-Policy: prefetch-src <source> <source>;

ソース

<source> は、 CSP ソース値にあるいずれかの値を取ることができます。

なお、この同じ値のセットはすべてのフェッチディレクティブ(と 他の多くのディレクティブ)で使用できます。

ヘッダーが一致しないリソースの事前読み込み

次のコンテンツセキュリティポリシーを持つページがあったとします。

http
Content-Security-Policy: prefetch-src https://example.com/

次のコードで読み込もうとすると、指定された URL が prefetch-src のソース一覧にないので、ネットワークエラーになります。

html
<link rel="prefetch" href="https://example.org/" />
<link rel="prerender" href="https://example.org/" />

仕様書

No specification found

No specification data found for http.headers.Content-Security-Policy.prefetch-src.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
prefetch-src
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.

関連情報