Skip to content

fix: add cache: 'no-store' to all fetch to prevent empty 304#1457

Merged
CodeWithCJ merged 2 commits into
CodeWithCJ:mainfrom
apedley:mobile-fix-cache
Jun 6, 2026
Merged

fix: add cache: 'no-store' to all fetch to prevent empty 304#1457
CodeWithCJ merged 2 commits into
CodeWithCJ:mainfrom
apedley:mobile-fix-cache

Conversation

@apedley

@apedley apedley commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Tip

Help us review and merge your PR faster!
Please ensure you have completed the Checklist below.
For Frontend changes, please run pnpm run validate to check for any errors.
PRs that include tests and clear screenshots are highly preferred!
Note: AI-generated descriptions must be manually edited for conciseness. Do not paste raw AI summaries.

Description

Fixes an issue where the iOS app could show 'Failed to Load.' This adds cache: 'no-store' to every GET requst which makes the polyfill append a timestamp query parameter for cache busting. This required me to add the parameter to the two strict zod schemas we have (exercise related.)

Linked Issue: Closes #1353 again

How to Test

  1. Don't strip cache headers
  2. Try to reload mobile app

PR Type

  • Issue (bug fix)
  • New Feature
  • Refactor
  • Documentation

Checklist

All PRs:

  • [MANDATORY - ALL] Integrity & License: I certify this is my own work, free of malicious code, and I agree to the License terms.

New features only:

  • [MANDATORY for new feature] Alignment: I have raised a GitHub issue and it was reviewed/approved by maintainers or it was approved on Discord.

Frontend changes (SparkyFitnessFrontend/):

  • [MANDATORY for Frontend changes] Quality: I have run pnpm run validate and it passes.
  • [MANDATORY for Frontend changes] Translations: I have only updated the English (en) translation file.

Backend changes (SparkyFitnessServer/):

  • [MANDATORY for Backend changes] Code Quality: I have run typecheck, lint, and tests. New files use TypeScript, new endpoints have Zod schemas, and new endpoints include tests.
  • [MANDATORY for Backend changes] Database Security: I have updated rls_policies.sql for any new user-specific tables.

UI changes (components, screens, pages):

  • [MANDATORY for UI changes] Screenshots: I have attached Before/After screenshots below.

Mobile changes (SparkyFitnessMobile/):

  • [MANDATORY for Mobile changes] Tested on device or emulator: I have verified the changes work on iOS or Android.

Screenshots

Click to expand

Before

before

After

after

Notes for Reviewers

Optional — use this for anything that doesn't fit above: known tradeoffs, areas you'd like specific feedback on, qustions you have or context that helps reviewers.

@github-actions github-actions Bot added backend bug Something isn't working mobile labels Jun 6, 2026
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

PR Validation Results

Change Detection

  • ⚙️ Backend changes detected
  • 📱 Mobile changes detected

✅ All checks passed. Thank you!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses issue #1353 by adding cache: 'no-store' to various fetch requests in the mobile application. This forces React Native's whatwg-fetch polyfill to append a _ cache-buster parameter to GET requests, preventing native HTTP caches from returning empty 304 responses. The server-side Zod schemas and tests have also been updated to tolerate this new parameter. Feedback on these changes includes conditionally applying the cache: 'no-store' option only to GET requests in apiClient.ts (and updating tests accordingly) to avoid unexpected side effects on state-changing requests, as well as wrapping a fetch call in OnboardingScreen.tsx in a try...finally block to guarantee clearTimeout is executed even if the request fails.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread SparkyFitnessMobile/src/services/api/apiClient.ts Outdated
Comment thread SparkyFitnessMobile/__tests__/services/api/apiClient.test.ts Outdated
Comment thread SparkyFitnessMobile/src/screens/OnboardingScreen.tsx
@apedley apedley marked this pull request as draft June 6, 2026 08:00
@apedley apedley marked this pull request as ready for review June 6, 2026 08:09
@CodeWithCJ CodeWithCJ merged commit 7b697ae into CodeWithCJ:main Jun 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working mobile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: App shows "Failed to Load Summary" after a first successful try

2 participants