perf: use If-Modified-Since for conditional metadata fetches (#11161)

Before fetching package metadata from the registry, stat the local cache
file and send its mtime as an If-Modified-Since header. If the registry
returns 304 Not Modified, read the local cache instead of downloading
the full response body. This saves bandwidth and latency for packages
whose metadata hasn't changed since the last fetch.

Registries that don't support If-Modified-Since simply return 200 as
before, so there is no behavior change for unsupported registries.
This commit is contained in:
Zoltan Kochan authored and GitHub committed 2026-04-01 12:39:13 +02:00
1 parent 52ee08aad4
commit 421d120972
7 files changed
+196 -8

No files matched your search

+2
View File
@@ -13,6 +13,8 @@ export type FetchFromRegistry = (
authHeaderValue?: string
compress?: boolean
fullMetadata?: boolean
ifModifiedSince?: string
ifNoneMatch?: string
retry?: RetryTimeoutOptions
timeout?: number
}