Skip to content

stale-while-revalidate not triggering background revalidation in either bypass_request or strict mode #684

@Seanw265

Description

@Seanw265

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:

  • strict follows HTTP caching RFCs literally.
  • bypass_request ignores 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-maxage but 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-maxage but within SWR: MISS and synchronous revalidation
  • Result: stale content is never served during SWR

Summary

  • bypass_request serves stale but never revalidates.
  • strict never serves stale once s-maxage expires.
  • In both cases, stale-while-revalidate appears 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions