fix: prevent stale personalized cache and preserve page edits#436
fix: prevent stale personalized cache and preserve page edits#436cursor[bot] wants to merge 1 commit into
Conversation
Co-authored-by: theg1239 <theg1239@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes three related bugs: stale personalized HTML being served by the service worker after sign-out, incorrect thumbnails in the moderation page-fixer when saved page edits exist, and split-view PDF rendering ignoring saved page fixes.
Confidence Score: 4/5Safe to merge — all three bugs are addressed by well-scoped, targeted changes with no regressions in the data flow or rendering paths. The service worker changes correctly guard all write sites except one: the background-refresh branch inside cacheFirst's cache-hit path still uses the old response.ok && !opaque check. For static assets this is benign in practice, but it leaves a small gap in the consistency of the new isCacheableResponse contract. The PDF page-edit and split-view changes look correct and the Redis cache key bump ensures old entries are evicted. public/sw.js — the cacheFirst background-refresh write at line 185 was not updated to use isCacheableResponse. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["SW fetch event (navigate/HTML)"] --> B{isUncacheable?}
B -- "/ or /auth or /api/..." --> C[Pass through — no cache]
B -- No --> D[staleWhileRevalidate]
D --> E[Fetch network response]
E --> F{isCacheableResponse?}
F -- "private/no-store/no-cache/set-cookie" --> G[Discard — not cached]
F -- Yes --> H[Write to PAGE_CACHE]
|
| @@ -1,4 +1,4 @@ | |||
| const CACHE_VERSION = "v3"; | |||
| const CACHE_VERSION = "v4"; | |||
There was a problem hiding this comment.
The PR title reads well as a conventional commit, but individual commit messages in this branch would benefit from being more descriptive — stating why each change was made, not just what changed (e.g., "bump SW cache version to v4 to evict stale user-personalized page cache" rather than just a generic description). This makes bisecting and blame much easier for the team.
Context Used: Encourage people to write better commit messages (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
/,/auth, private/no-store/no-cache responses, or Set-Cookie responses; bump the SW cache version to evict previously cached personalized home HTML.pageEditsin course paper list data and pass them into split-view PDF rendering/markdown extraction.Bug and impact
Root cause
pageEditsinto the split-view item.Validation
pnpm exec tsx -e ...targeted page-edit render mapping regression check passed.node -e ...targeted service-worker cache guard check passed.pnpm exec tsc --noEmit --pretty falsepassed.pnpm buildpassed with local placeholder env and PostgreSQL service.