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:
1 parent
52ee08aad4
commit
421d120972
7 files changed
+196
-8
No files matched your search
@@ -13,6 +13,8 @@ export type FetchFromRegistry = (
|
||||
authHeaderValue?: string
|
||||
compress?: boolean
|
||||
fullMetadata?: boolean
|
||||
ifModifiedSince?: string
|
||||
ifNoneMatch?: string
|
||||
retry?: RetryTimeoutOptions
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user