Skip to content

304 revalidation doesn't freshen the stored response (RFC 9111 §4.3.4) #809

@u5surf

Description

@u5surf

When a revalidation returns 304, Souin reuses the stored response but never updates it with the 304's headers: Revalidate() skips storing on 304 (middleware.go:727) and the serve path (middleware.go:1105-1118) replays the old headers. So Date/Cache-Control are never refreshed and every later request re-revalidates — the validation is wasted.

RFC 9111 §4.3.4: "the cache MUST update its header fields with the header fields provided in the 304" — and §4.3.3 says a 304 means the stored response is reused, so the MUST applies.

Proposal: on a 304, merge the 304's headers into the stored response and re-store it (§3.2) before serving, with a test that a later request is then served without re-revalidating.

@darkweak does this match your understanding?

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