Repository navigation
Conversation
Every Composer archive download fetched the package's p2 metadata straight from upstream to find the archive's URL, before the archive cache was even checked. A cached archive cost one or two uncached Packagist requests per package and install, and failed with a 502 while Packagist was down. With cache_metadata on, downloads now look the dist up in the metadata the proxy already caches for Composer, under the keys handlePackageMetadata uses. Within the TTL that needs no upstream request, and when upstream fails the stale copy still resolves the archive. A version or file the cached documents do not list, such as one published since they were cached, is looked up upstream as before.
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.
Every Composer archive download fetched the package's
p2metadata straight from upstream to find the archive URL (findDownloadURLFromMetadata, a plainHTTPClient.Do), before the archive cache was checked. So a cached archive still cost one or two uncached Packagist requests per package on everycomposer install, and failed with a 502 while Packagist was down, even though the archive itself was on disk.With
cache_metadataon,handleDownloadnow first looks the dist up in the metadata the proxy already caches for Composer, throughfetchMetadataDocumentand under the same cache keyshandlePackageMetadatastores thep2and~devdocuments under (routed packages included). That means:metadata_ttla download needs no upstream request, since Composer has usually just fetched that document through the proxy. When the TTL has passed it revalidates with the ETag and shares the fetch with concurrent callers like any other metadata request.Without
cache_metadatanothing changes; the cached step is skipped so a download still makes exactly one upstream metadata request.The cooldown check and the dev-branch
?sha=/ commit handling run on the resolved dist as before. A short note is added to the Metadata Caching section ofdocs/configuration.md.Tests
composer_download_lookup_test.go:TestComposerDownloadResolvesFromCachedMetadata: metadata request plus two downloads cost one upstream metadata request (3 before).TestComposerCachedArchiveServedWhileUpstreamDown: a cached archive is served while upstream returns 503 (404 before, as the failed lookup read as "version not found").TestComposerDownloadOfVersionNewerThanCachedMetadata: a version missing from the cached metadata is still resolved upstream.TestComposerDownloadWithoutMetadataCache: one metadata request per download withoutcache_metadata.The first two fail on main; the third fails if the upstream fallback is removed.
go test -race ./...andgolangci-lintpass.