Repository navigation
fix(auth): keep private route cache policies on authenticated responses - #408
Merged
Merged
Conversation
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-auth-keep-route-cache-control-void-cloud.voidzero-docs.workers.dev (commit 8b0c224)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
A bare `private` still lets the browser reuse a signed-in response without asking the Worker, so the next account on the same browser can see it. Keep the route's Cache-Control only when it has `no-store`, or `private` together with `no-cache`. Every other policy gets the session lookup's `no-store`, as before. Parse directives with quoted values intact, so a comma inside a quoted value can't produce a false bare directive. Document `etag()` for 304s, per-user ETags, and the Back button limit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Brooooooklyn
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Void's auth middleware copies the session lookup's
cache-control: no-storeandpragma: no-cacheonto every signed-in response. This overwrites the route's own policy. So signed-in data can never be revalidated:private, no-cacheplus anETagnever gives a304.What this PR changes
private, no-store). The rotatedSet-Cookieis still sent.no-cache="a,private"does not make a bareprivate.Decisions
private?private, no-cache?304case.Clear-Site-Dataon sign-out?Known limits
304, not Void. Use Hono'setag()middleware.ETagmust differ per user. Otherwise user B can get a304for user A's cached page.private, no-cachepage after sign-out. Pages that must not stay in the browser cache should keep the defaultno-store.Shared caches stay safe: ISR and dispatch skip requests with credentials, and they never store
private,no-cacheorno-store.Testing
auth-isr-cache-policy.test.ts(real Better Auth)no-storetables, quoted values, case and tab variants,etag()304end to endauth-middleware.test.tsvp run test,vp run check, lint, fmt🤖 Generated with Claude Code