What is the difference between "ttl" and "stale" in cache-handler / souin module?

sorry if it is a stupid question.

edit:

i found it in docs.souin.io

Stale
The stale prefix configure the duration to keep the stale responses in the storage. (e.g. default_cache.stale).
example: 1d

TTL
The ttl prefix configure the duration to keep the fresh responses in the storage. (e.g. default_cache.ttl).
example: 10m

but my question now is, why keep stale response? in what condition does souin serve stale response?

With a fresh response in the cache, when requested, caddy directly serves the file to the end user

With a stale response in the cache, caddy asks the backend server if the file got updated. The backend server can just say “304 not modified” and caddy uses the file from the cache instead of downloading it again from caddy.

1 Like