コンテンツにスキップ

注文と優先順位

キャッシュルールは、ページルールとは異なる方法でリクエストに影響を与えます。これが適用される方法です:

  1. キャッシュルールはスタッカブルです。これは、複数の一致するルールを組み合わせて同じリクエストに適用できることを意味します。たとえば、複数のキャッシュルールが同じURLに一致する場合、それらのキャッシュルールに設定された機能はすべて順番に適用されます。複数の一致するルールが同じ設定の値を設定している場合、最後に一致したルールの値が勝ちます。複数のルールが一致する類似のシナリオの例については、Origin Rules FAQを参照してください。

  2. 矛盾する設定(たとえば、キャッシュをバイパスする対キャッシュの対象となる)については、最後に一致したルールが勝ちます。たとえば、キャッシュルール#1がexample.com/imagesのすべてをキャッシュするように設定され、キャッシュルール#2がexample.comでキャッシュをバイパスするように設定されている場合、ルール#2が最後の一致したルールであるため、example.comに一致するすべてのURLのキャッシュはバイパスされます。

  3. 同じパスでキャッシングのためにページルールが実装されている場合、キャッシュルールは設計上優先されます。

  4. キャッシュルールは、キャッシュ設定タブのウェブサイト全体の設定よりも具体的であるため、一致するリクエストに対してウェブサイト全体の設定よりも優先されます。たとえば、ブラウザキャッシュTTLがウェブサイト全体example.comに対して4時間に設定されており、パス/feedのリクエストに一致するキャッシュルールがブラウザキャッシュTTLを10秒に設定している場合、キャッシュルールはhttps://example.com/feedへのリクエストに対するウェブサイト全体の設定を上書きします。

ルール製品の実行順序

The execution order of Rules features is the following:

The different types of rules listed above will take precedence over Page Rules. This means that Page Rules will be overridden if there is a match for both Page Rules and the Rules products listed above.

Generally speaking, for non-terminating actions the last change made by rules in the same phase will win (later rules can overwrite changes done by previous rules). However, for terminating actions (Block, Redirect, or one of the challenge actions), rule evaluation will stop and the action will be executed immediately.

For example, if multiple rules with the Redirect action match, Cloudflare will always use the URL redirect of the first rule that matches. Also, if you configure URL redirects using different Cloudflare products (Single Redirects and Bulk Redirects), the product executed first will apply, if there is a rule match (in this case, Single Redirects). Refer to the Phases list for the product execution order.