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
- Do not cache private user pages unless the route is explicitly safe.
- Keep cache keys bounded and predictable.
- content가 자주 바뀌면 purge 또는 짧은 TTL을 사용하세요.
- cookie, authorization, preview header, unsafe query string에서는 bypass합니다.