-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
I'm having trouble getting Souin to honor stale-while-revalidate as expected.
Setup
{
cache {
ttl 100s
stale 3h
default_cache_control public, s-maxage=100
mode bypass_request
}
}
:80 {
cache
reverse_proxy test-server:8080
}Origin response:
Cache-Control: public, s-maxage=10, stale-while-revalidate=60
All test requests are made without any Cache-Control request headers.
Cache modes and expectations
My understanding is:
strictfollows HTTP caching RFCs literally.bypass_requestignores Cache-Control request headers but still honors Cache-Control response headers.
Since I am not sending any Cache-Control request headers, I expect both modes to behave the same.
Expected Behavior
- First request: MISS
- Second request (within
s-maxage=10): HIT - After
s-maxagebut within SWR: serve stale and revalidate in the background - After SWR expires: revalidate or refetch before serving
Actual Behavior
bypass_request
- First request: MISS
- Second request: HIT
- After
s-maxage: stale is served, but revalidation never occurs - Result: stale content persists indefinitely
strict
- First request: MISS
- Second request: HIT
- After
s-maxagebut within SWR: MISS and synchronous revalidation - Result: stale content is never served during SWR
Summary
bypass_requestserves stale but never revalidates.strictnever serves stale onces-maxageexpires.- In both cases,
stale-while-revalidateappears to have no effect. - The difference between the modes is unexpected, because no Cache-Control request headers are being sent.
Please let me know if this is a configuration issue or if I am misunderstanding something. I'm new to Souin so it's certainly possible there's something I've missed.
sveniu
Metadata
Metadata
Assignees
Labels
No labels