キャッシュのカスタマイズ
オリジンウェブサーバーの設定とCloudflareのキャッシュルールの組み合わせのいくつかは以下の通りです。
例えば、オリジンウェブサーバーに/static/というサブディレクトリを作成し、次の式に一致するキャッシュすべてのキャッシュルールを作成します。
- Expression Builderを使用:
Hostname contains "example.com" AND URI Path starts with "/static" - Expression Editorを使用:
(http.host contains "example.com" and starts_with(http.request.uri.path, "/static"))
例えば、オリジンウェブサーバーのリソースに対して.shtmlファイル拡張子を作成し、次の式に一致するキャッシュすべてのキャッシュルールを作成します。
- Expression Builderを使用:
Hostname contains "example.com" AND URI Path ends with ".shtml" - Expression Editorを使用:
(http.host contains "example.com" and ends_with(http.request.uri.path, ".shtml"))
例えば、オリジンウェブサーバーのリソースに対してstatic=trueというクエリ文字列を追加し、次の式に一致するキャッシュすべてのキャッシュルールを作成します。
- Expression Builderを使用:
Hostname contains "example.com" AND URI Query String contains "static=true" - Expression Editorを使用:
(http.host contains "example.com" and http.request.uri.query contains "static=true")
キャッシュすべてのキャッシュルールに一致するリソースは、オリジンウェブサーバーがmax-age=0、private、no-cacheのCache-Controlヘッダー、またはすでに期限切れの日付を持つExpiresヘッダーを送信した場合、キャッシュされません。キャッシュすべてのキャッシュルール内にEdge Cache TTL設定を含めて、オリジンウェブサーバーからのCache-Controlヘッダーを上書きすることができます。