Skip to content

fix(middleware): freshen stored response on 304 revalidation#821

Open
u5surf wants to merge 1 commit into
darkweak:masterfrom
u5surf:fix/freshen-stored-response-304
Open

fix(middleware): freshen stored response on 304 revalidation#821
u5surf wants to merge 1 commit into
darkweak:masterfrom
u5surf:fix/freshen-stored-response-304

Conversation

@u5surf

@u5surf u5surf commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

When a revalidation returns 304 (Not Modified), the stored response was reused but never updated with the 304's header fields, so its freshness metadata (Date, Cache-Control) stayed stale and every later request re-revalidated — the validation was wasted.

Merge the 304's headers into the stored response and re-store it through a throwaway writer (leaving the client-facing response untouched) so the entry becomes fresh again, as required by RFC 9111 §4.3.4 (§3.2 update semantics). Wired into all five revalidation call sites, including the background stale-while-revalidate path.

Closes #809

When a revalidation returns 304 (Not Modified), the stored response was
reused but never updated with the 304's header fields, so its freshness
metadata (Date, Cache-Control) stayed stale and every later request
re-revalidated — the validation was wasted.

Merge the 304's headers into the stored response and re-store it through
a throwaway writer (leaving the client-facing response untouched) so the
entry becomes fresh again, as required by RFC 9111 §4.3.4 (§3.2 update
semantics). Wired into all five revalidation call sites, including the
background stale-while-revalidate path.

Closes darkweak#809

Signed-off-by: Y.Horie <u5.horie@gmail.com>
@netlify

netlify Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploy Preview for teal-sprinkles-4c7f14 canceled.

Name Link
🔨 Latest commit fd26156
🔍 Latest deploy log https://app.netlify.com/projects/teal-sprinkles-4c7f14/deploys/6a3a7eae8c2eca00080bc1d8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant