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-tjeneste-tjenesteBruk det når
memoryYou need the fastest cache and can keep objects in RAM.
diskYou need cache capacity that survives process restarts.
tieredDu vil ha minne for varme objekter og disk for større kapasitet.
storage-binDu forventer mye utskifting og vil ha begrenset diskallokering.
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

KontrollFormål
lockCollapse concurrent misses so one request fills the cache.
range.sliceCache fixed byte slices for large files and resumable downloads.
peer_fillLa én edge fylle fra en annen edge før origin brukes.
origin_protectionBegrens samtidige origin-fyllinger under høyt trykk.
cache_purgerRydd gamle diskoppføringer i begrensede batcher.

Use cache carefully

  • Do not cache private user pages unless the route is explicitly safe.
  • Keep cache keys bounded and predictable.
  • Bruk purge eller korte TTL-er når innhold endres ofte.
  • Bypass ved cookies, autorisasjon, preview-headere og usikre query strings.
Norsk