Fix fetch cache for subsequent 404 responses #70259
Open
+143
−1
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.
What?
Consuming an API with active fetch cache can return 200 responses at one point which land in the fetch cache. If now subsequent requests of the same route return 404 (e.g. in a webshop an article got deactivated), the fetch cache still returns stale data. More details: #62920
Why?
Patched fetch does the subsequent http call anyways, just the stale data is returned.
How?
Allowing patch-fetch to override existing cache entries with status 404. There might be alternative solutions to this, but I didn't see a method to just remove the cache entry here and returning the new data.
Adding testcase to make multiple http calls in jest where the first call is returning 200 status and the second 404.
Fixes #62920