Skip to content
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

Fix fetch cache for subsequent 404 responses #70259

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from

Conversation

florianliebig
Copy link

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

@ijjk
Copy link
Member

ijjk commented Sep 19, 2024

Allow CI Workflow Run

  • approve CI run for commit: 8372b80

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[App Router -> Caching] Fetch cache is not revalidating for pages that have turned into 404 errors.
2 participants