캐시 커스터마이즈
캐시 커스터마이즈 (Customize cache)
오리진 웹 서버 설정과 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"))
리소스 URL에 쿼리 문자열을 추가해 콘텐츠를 정적으로 표시
예를 들어 오리진 웹 서버의 리소스에 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 Everything Cache Rule에 Edge Cache TTL 설정을 포함하면 오리진 웹 서버의 Cache-Control 헤더를 추가로 덮어쓸 수 있어요.
더 알아보기 (Learn more)
오리진 설정과 Cache Rules를 조합해 정적 콘텐츠를 식별하고 더 많은 리소스를 캐시할 수 있어요. Cache Everything 규칙과 Edge Cache TTL 설정을 함께 사용하면 오리진의 Cache-Control 헤더를 덮어써 캐시 동작을 제어할 수 있어요.