fix: cache 404 responses for remote modules#35138
Open
bartlomieju wants to merge 1 commit into
Open
Conversation
…very run A remote module that responded with 404 was never written to the HTTP cache, so the URL was re-requested during graph resolution on every process start (ex. JSDoc type references in published jsr packages that point at non-existent files, or dynamic imports that 404). Store a body-less cache entry marked with a synthetic x-deno-not-found header (the same pattern as redirects, which are stored body-less and detected via their location header) and serve "not found" from the cache for 15 minutes. Authenticated requests are not negatively cached since a 404 may depend on credentials. --reload bypasses the negative cache as usual. Closes #25404
Member
|
Need to make sure this has a TTL wired up so that it picks up on files if they no longer 404 |
Member
Author
|
This is wired up. There's a 15-minute TTL (
The expiry path is covered by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A remote module that responds with 404 is never written to the HTTP cache,
so the URL is re-requested during graph resolution on every process start.
This shows up with published jsr packages whose JSDoc type references point
at non-existent files (every run of an installed CLI re-downloads the same
handful of 404ing URLs) and with dynamic imports that 404.
This stores a body-less cache entry marked with a synthetic
x-deno-not-found header, the same pattern used for redirects (body-less
entries detected via their location header), and serves "not found" from
the cache for 15 minutes. The TTL keeps a resource that appears on the
remote server later (e.g. a freshly published package version that is
still propagating) from being missed for long, while eliminating the
re-fetch on every run. Authenticated requests are not negatively cached
because a 404 can depend on the provided credentials (private registries
respond with 404 for unauthorized requests). --reload bypasses the
negative cache like it does everything else.
Closes #25404