fix(api): let the browser revalidate GETs with ETags - #505
Merged
Merged
Conversation
Drop the Cache-Control/Pragma/Expires defaults on axios GETs. no-store kept the browser from storing responses, so it never sent If-None-Match and the backend's 304s could not apply. The backend now sends private, no-cache for user data and public, max-age=60 for game data. Deploy only after the backend change (PRUNplanner/backend, same branch) is live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for prunplanner-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
3 tasks
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
🟢 Coverage ∅ diff coverage · 0.00% coverage variation
Metric Results Coverage variation ✅ 0.00% coverage variation (-1.00%) Diff coverage ✅ ∅ diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (c473d72) 2863 2774 96.89% Head commit (91f65aa) 2860 (-3) 2771 (-3) 96.89% (0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#505) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Summary
Removes the
Cache-Control: no-cache, no-store, must-revalidate,Pragma: no-cacheandExpires: 0defaults on axios GETs insrc/lib/apiService.ts.no-storekept the browser from storing responses, so it never sentIf-None-Match. The backend's new ETags and 304s could never apply.What the SPA gets from the backend after this:
private, no-cache. The browser revalidates every request. It gets a304with no body when nothing changed, and a200after a save, because the version bump changes the ETag.public, max-age=60. That is much shorter than the query store's own staleness.Axios runs on XHR, so a 304 reaches it as a 200 with the cached body. Zod validation, the query store and IndexedDB behave the same.
Merge only after PRUNplanner/backend#50 is live. With the old backend, dropping
no-storewould let the browser reuse private responses for 1–3 h, including an old plan list after a save.Spec:
specs/2026-09-27-cache-structure.md(workspace repo).Test plan
pnpm test && pnpm tsc && pnpm lint && pnpm knip304for the plan and empire requests. After a save, the refetch should return200with the new data.🤖 Generated with Claude Code