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 lucaleUsalo quanno
memoryYou need the fastest cache and can keep objects in RAM.
diskYou need cache capacity that survives process restarts.
tieredVuoi memory pe oggetti caldi e disk pe 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 nu edge 'e riempire da nu altro edge primma 'e usare origin.
origin_protectionLimita 'e fill origin concorrenti durante pressione alta.
cache_purgerPulisci entry disk stale in batch bounded.

Use cache carefully

  • 'E richieste cu Authorization o Proxy-Authorization saltano sempe 'a ricerca e 'o salvataggio dint''a cache condivisa.
  • 'E direttive 'e risposta Cache-Control malformate o 'n cunflitto veneno rifiutate invece 'e turnà ê TTL configurate; s-maxage tene priorità ncopp''a max-age.
  • must-revalidate, proxy-revalidate e s-maxage vietano 'e riusà dati stantie doppo ca fernesce 'a freschezza.
  • Keep cache keys bounded and predictable.
  • Usa na root storage-bin pe ogne processo Fluxheim in esecuzione; ’a proprietà usa nu lock consultivo d’ ’o filesystem e ’e root condivise cu cchiù writer nun so’ sicure senza locking esterno verificato.
  • Usa purge o TTL brevi quanno 'o contenuto cambia spesso.
  • Bypass on cookies, preview headers, and unsafe query strings.

Nota pe ll'aggiornamento d''a cache cifrata

Fluxheim 1.7.12 sposta ll'oggette d''a cache cifrata ncopp''o disco a chiave 'e date e indice legate â radice, cu nu stato nonce durevole. 'O primmo avvio ncopp''a na radice cifrata cchiù vecchia e ogne rotazione d''a chiave locale fanno apposta na pulizia a friddo d''a cache primma 'e servì 'o traffico.

  • Tratta 'a cache cifrata comme accelerazione ca se pò jettà, no comme fonte ufficiale d''e date.
  • Dà a ogne radice d''a cache nu spazio privato persistente e nun cupià 'o stato nonce fra radice indipendente.
  • Pianifica 'a capacità d''o server d''origine pe 'o primmo riscaldamento doppo ll'aggiornamento o 'a rotazione d''e chiave.
Napulitano