オリジンウェブサーバーの設定と Cloudflare の Cache Rules を組み合わせる例は、次のとおりです。
たとえば、オリジンウェブサーバーに /static/ サブディレクトリを作り、次の式に一致する Cache Everything の Cache Rule を作成します。
- 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 拡張子を付け、次の式に一致する Cache Everything の Cache Rule を作成します。
- 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 クエリ文字列を付け、次の式に一致する Cache Everything の Cache Rule を作成します。
- 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")
Cache Everything の Cache Rule に一致するリソースでも、オリジンウェブサーバーが max-age=0、private、no-cache の Cache-Control ヘッダー、またはすでに期限切れの日付の Expires ヘッダーを送るとキャッシュされません。オリジンウェブサーバーの Cache-Control ヘッダーも上書きするには、Cache Everything の Cache Rule に Edge Cache TTL 設定を含めます。