Alana Storm
Alana Storm

Reputation: 166076

PHP Composer: Debugging a Cache Miss for a Custom Repository's packages.json

I'm using PHP composer with a custom repository. For reasons that are beyond my ability to debug myself, composer is downloading the repository's packages.json every time I run a command.

$ composer.phar --profile -vvv --no-dev --repository-url=http://packages.firegento.com create-project magento-hackathon/magento-composer-installer .
[4.2MB/0.05s] Downloading http://packages.firegento.com/packages.json
[70.6MB/152.18s] Writing /Users/alanstorm/.composer/cache/repo/http---packages.firegento.com/packages.json into cache
...

$ composer.phar --profile -vvv update
[3.7MB/0.01s] Reading ./composer.json
[4.2MB/0.02s] Executing command (CWD): git describe --exact-match --tags
[4.4MB/0.03s] Executing command (CWD): git branch --no-color --no-abbrev -v
[4.5MB/0.05s] Executing command (CWD): hg branch
[4.5MB/0.12s] Executing command (CWD): svn info --xml
[6.6MB/0.17s] Loading composer repositories with package information
[6.8MB/0.19s] Downloading http://packages.firegento.com/packages.json
[73.2MB/125.50s] Writing /Users/alanstorm/.composer/cache/repo/http---packages.firegento.com/packages.json into cache

That's 152.18s seconds for the first read, and 125.50s seconds for the second.

This runs counter to the behavior of the standard packagist packages.json, which composer seems to download once and then read from cache.

How can I debug this cache miss further? I don't know enough about composer to quickly track down where the "do i need to grab this from cache" logic lives, and I don't control the custom repository server.

Also, it's possible I'm completely wrong about the cache hit/miss theory, so any other ideas on this slow behavior are appreciated.

Upvotes: 2

Views: 744

Answers (1)

Alana Storm
Alana Storm

Reputation: 166076

Composer, by design, doesn't cache the main packages.json file, so my question about a cache miss was invalid. If you're seeing a slow download of packages.json, your best bet is to

  1. Enable gzip compression on the server serving this file.

  2. Splitting up the packages.json file into multiple files.

Upvotes: 1

Related Questions