Skip to content

fix(api): let the browser revalidate GETs with ETags - #505

Merged
jplacht merged 1 commit into
mainfrom
fix/cache-structure
Sep 27, 2026
Merged

jplacht merged 1 commit into
mainfrom
fix/cache-structure

Conversation

@jplacht

@jplacht jplacht commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the Cache-Control: no-cache, no-store, must-revalidate, Pragma: no-cache and Expires: 0 defaults on axios GETs in src/lib/apiService.ts.

no-store kept the browser from storing responses, so it never sent If-None-Match. The backend's new ETags and 304s could never apply.

What the SPA gets from the backend after this:

  • Private data (plans, empires, storage, profile): private, no-cache. The browser revalidates every request. It gets a 304 with no body when nothing changed, and a 200 after a save, because the version bump changes the ETag.
  • Game data: 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.

⚠️ Deploy order

Merge only after PRUNplanner/backend#50 is live. With the old backend, dropping no-store would 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 knip
  • After backend deploy: reload an unchanged plan page and check the Network tab shows 304 for the plan and empire requests. After a save, the refetch should return 200 with the new data.

🤖 Generated with Claude Code

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>
@netlify

netlify Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for prunplanner-preview ready!

Name Link
🔨 Latest commit 91f65aa
🔍 Latest deploy log https://app.netlify.com/projects/prunplanner-preview/deploys/6ab92dba93994c0008534aab
😎 Deploy Preview https://deploy-preview-505--prunplanner-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codacy-production

codacy-production Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · 0.00% coverage variation

Metric Results
Coverage variation ✅ 0.00% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

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.

@jplacht
jplacht merged commit bfa88b2 into main Sep 27, 2026
14 checks passed
@jplacht
jplacht deleted the fix/cache-structure branch September 27, 2026 16:10
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.

1 participant