Skip to content

feat(middleware): don't cache responses with a Set-Cookie header#806

Open
u5surf wants to merge 1 commit into
darkweak:masterfrom
u5surf:feat/skip-store-set-cookie
Open

feat(middleware): don't cache responses with a Set-Cookie header#806
u5surf wants to merge 1 commit into
darkweak:masterfrom
u5surf:feat/skip-store-set-cookie

Conversation

@u5surf

@u5surf u5surf commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

A Set-Cookie response is typically tied to a single user; storing it in a shared cache replays one user's cookie to every subsequent client. Match the default of nginx/Varnish/Fastly/Cloudflare and skip storing such responses (detail=UNCACHEABLE-SET-COOKIE).

Closes #805

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for teal-sprinkles-4c7f14 canceled.

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

@darkweak

Copy link
Copy Markdown
Owner

Can you rebase @u5surf?

@u5surf
u5surf force-pushed the feat/skip-store-set-cookie branch from fb89e94 to 03fc2ae Compare June 23, 2026 10:59
A Set-Cookie response is typically tied to a single user; storing it in
a shared cache replays one user's cookie to every subsequent client.
Match the default of nginx/Varnish/Fastly/Cloudflare and skip storing
such responses (detail=UNCACHEABLE-SET-COOKIE).

The exception is an explicit Cache-Control: no-cache="Set-Cookie"
directive, which strips the field from the stored response: there is
nothing to leak, so the rest of the response is still cached (preserving
the existing TestSetCookieNotStored behavior).

Closes darkweak#805

Signed-off-by: Y.Horie <u5.horie@gmail.com>
@u5surf
u5surf force-pushed the feat/skip-store-set-cookie branch from 03fc2ae to 15bae64 Compare June 25, 2026 11:11
@darkweak

Copy link
Copy Markdown
Owner

The opt-in to keep the current behavior is missing.
Thank you for your contributions!

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.

Don't store Set-Cookie responses by default (cookie leak risk)

2 participants