Cache
Use cache when Fluxheim sits in front of an origin and repeated responses should be served faster.
Proxy cache example
[cache]
enabled = true
default_ttl_secs = 300
max_object_bytes = "32MiB"
status_header = "X-Cache-Status"
[cache.memory]
enabled = true
max_size_bytes = "256MiB"
[cache.disk]
enabled = true
path = "/var/cache/fluxheim/site"
max_size_bytes = "10GiB"
Cache backends
| 백엔드 | 사용할 때 |
|---|---|
memory | You need the fastest cache and can keep objects in RAM. |
disk | You need cache capacity that survives process restarts. |
tiered | hot object에는 memory를, 더 큰 capacity에는 disk를 원할 때. |
storage-bin | 변경이 많고 제한된 disk allocation을 원할 때. |
encrypted disk | You need cache-at-rest protection for disk objects. |
Route cache policy
[[vhosts.routes]]
name = "assets"
path_prefix = "/assets/"
action = "proxy"
[vhosts.routes.proxy]
upstreams = ["127.0.0.1:3000"]
[vhosts.routes.cache]
enabled = true
status_ttls = { "200" = 3600, "404" = 60 }
content_types = ["text/css", "application/javascript", "image/*"]
extensions = ["css", "js", "png", "webp", "svg"]
include_query = false
stale_while_revalidate_secs = 30
stale_if_error_secs = 120
Advanced cache controls
| 제어 | 목적 |
|---|---|
lock | Collapse concurrent misses so one request fills the cache. |
range.slice | Cache fixed byte slices for large files and resumable downloads. |
peer_fill | origin을 사용하기 전에 한 edge가 다른 edge에서 fill하도록 합니다. |
origin_protection | 압력이 높을 때 concurrent origin fill을 제한합니다. |
cache_purger | stale disk entry를 제한된 batch로 정리합니다. |
Use cache carefully
Authorization또는Proxy-Authorization를 전달하는 요청은 항상 공유 캐시 조회 및 저장을 우회합니다.- 잘못된 형식 또는 충돌하는 응답
Cache-Control지시문은 구성된 TTL로 돌아가는 대신 거부됩니다.s-maxage는max-age보다 우선순위를 갖습니다. must-revalidate,proxy-revalidate및s-maxage는 최신 상태가 만료된 후 오래된 재사용을 금지합니다.- Keep cache keys bounded and predictable.
- 실행 중인 Fluxheim process마다 storage-bin root를 하나씩 사용하십시오. 소유권은 advisory filesystem lock으로 관리되므로 검증된 외부 locking이 없는 공유 multi-writer root는 안전하지 않습니다.
- 콘텐츠가 자주 바뀌면 purge 또는 짧은 TTL을 사용하세요.
- Bypass on cookies, preview headers, and unsafe query strings.
암호화된 캐시 업그레이드 참고 사항
Fluxheim 1.7.12는 암호화된 디스크 캐시 객체를 내구성 있는 nonce 상태를 사용하여 루트 바인딩된 데이터 및 인덱스 키로 이동합니다. 이전에 암호화된 루트에 대한 첫 번째 시작과 모든 로컬 키 순환은 트래픽을 제공하기 전에 의도적으로 해당 캐시를 콜드 퍼지합니다.
- 암호화된 캐시는 기준 데이터가 아니라 폐기 가능한 성능 가속 데이터로 취급합니다.
- 모든 캐시 루트에 영구 개인 저장소를 제공하고 독립 루트 간에 nonce 상태를 복사하지 마세요.
- 업그레이드 또는 키 교체 후 첫 캐시 재구축에 필요한 오리진 서버 용량을 계획합니다.