cannot get 304 Not modified status from fetch #44483
Labels
Issue: Author Provided Repro
This issue can be reproduced in Snack or an attached project.
Needs: Author Feedback
Needs: Triage 🔍
🌐Networking
Related to a networking API.
Description
I'm working on implementing a caching mechanism for images in a React Native application. This involves utilizing AWS S3 to store the image files and using JavaScript's fetch API to retrieve them. However, even after correctly adding the
If-Modified-Since
andIf-None-Match
headers in the fetch request, I'm facing an issue where the response.status property doesn't return a 304 status as expected.Initially, I do receive the anticipated 304 response. However, upon modifying the
If-None-Match
in the headers, the subsequent response switches to 200, as anticipated. What's perplexing is that upon reverting theIf-None-Match
to its original value, all subsequent requests consistently return 200. Shouldn't the fetch API consistently return a 304 status?I've extensively tested this behaviour across various HTTP clients, including Postman, cURL, and the fetch API in both browser and Node.js environments, all yielding 304 status always. Strangely, it seems that only the fetch API in React Native exhibits this behaviour.
Steps to reproduce
npm run android
ornpm run ios
, affects both platformIf-None-Match
headerIf-None-Match
back to its original value2c845032f84e1139a41c639609406664
, it will be200
200
from thereafter for that urlReact Native Version
0.74.1
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/alvinlalbit/react-native-cachetest
Screenshots and Videos
Screen.Recording.2024-05-08.at.4.20.20.PM.1.mov
The text was updated successfully, but these errors were encountered: