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

Backend łocałeUsalo coando
memoryYou need the fastest cache and can keep objects in RAM.
diskYou need cache capacity that survives process restarts.
tieredVuoi memory par oggetti caldi e disk par capacità maggiore.
storage-binTi aspetti churn alto e vuoi allocazione disk bounded.
encrypted diskYou 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

ControlloScopo
lockCollapse concurrent misses so one request fills the cache.
range.sliceCache fixed byte slices for large files and resumable downloads.
peer_fillPermetti a un edge de riempire da un altro edge prima de usare origin.
origin_protectionLimita i fill origin concorrenti durante pressione alta.
cache_purgerPulisci entry disk stale in batch bounded.

Use cache carefully

  • Łe richieste co Authorization o Proxy-Authorization łe salta sempre ła ricerca e el salvatagio inte ła cache condivixa.
  • Łe diretive de risposta Cache-Control malformade o in conflito łe vien rifiutade invese de tornar ai TTL configurài; s-maxage el ga priorità su max-age.
  • must-revalidate, proxy-revalidate e s-maxage i vieta de riutilixar dati veci dopo che ła frescheza ła xe scaduda.
  • Keep cache keys bounded and predictable.
  • Usa na sola root storage-bin par ogni processo Fluxheim in esecusion; la proprietà la usa un lock consultivo del filesystem e le root condivise multi-writer no le xe sicure sensa locking esterno verificà.
  • Usa purge o TTL brevi coando el contenuto cambia spesso.
  • Bypass on cookies, preview headers, and unsafe query strings.

Nota par l'ajornamento de ła cache cifrada

Fluxheim 1.7.12 el sposta i ojeti de ła cache cifrada su disco a ciavi dati e indixe łegade a ła radixe, co un stato nonce durevołe. El primo avìo su na radixe cifrada pì vecia e ogni rotasion de ła ciave locałe i purga aposta ła cache a fredo prima de servir el trafico.

  • Trata ła cache cifrada come acelerasion che se pol butar via, no come fonte ufisiałe dei dati.
  • Dà a ogni radixe de cache un spàsio privà persistente e no copiar el stato nonce tra radixe indipendenti.
  • Pianifica ła capacità de l'origine par el primo riscaldamento dopo l'ajornamento o ła rotasion de łe ciavi.
Vèneto