-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot get 304 Not modified status from fetch #44483
Comments
I have an issue on iOS that has been plaguing me for months where deep within my app, I'm getting these two headers (If-None-Match and If-Modified-Since) added to DELETE requests that I send to S3. I have met with the S3 team and they've determined that it has to be happening at the iOS level because the only network debugger that catches the two headers is Charles Proxy. This thread is slightly related. I will gladly get on a call and provide private repo access and steps to reproduce. |
After upgrading from 0.73.6 to 0.74.1 we experience a similar issue on iPhone 7. We implement a custom caching mechanism relying on 304 status code. POST requests that are supposed to return empty 304 now return 200 with previous data. It seems to be working as before on iPhone 8 and later, and Android. |
@alvinlalbit @madox2 Could you please try the fix above? Tough per Apple spec, this fix won't work on old iOS version. |
@alvinlalbit the reproducer you linked is incomplete, it doesn't have your changes on it. |
Hi @blakef , I created the reproducer repo, and my teammate made some updates to it. Could you please let me know which specific changes are missing so we can address it? Thanks! |
Hi, please try fix #45263 locally |
@alvinlalbit if you look in the repro you've shared it doesn't resemble the app you're describing. It looks like the default app. |
@blakef , sorry about that , made the required changes now 👍 |
hi @huzhanbo1996 , sure thing, will try your fix, do you have any resources on how to build react native from source from your forked branch ? |
Summary: In #44483 `If-None-Match` request failed to get a 304 after a 200 response. This is caused by NSRequest's cachePolicy which prevents sending a request to server to check 304 state and return directly a 200 response. ## Changelog: [IOS] [FIXED] - fix: on iOS not getting 304 from `If-None-Match` request Pull Request resolved: #45263 Test Plan: repeat request given in #44483 Reviewed By: cortinico Differential Revision: D59364609 Pulled By: dmytrorykun fbshipit-source-id: 2a8b86c526320a1e9c1c58e41aa9c74beeeac2ce
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: