Cache git repositories installed with Composer from source on Travis CI (and other CI tools)?
<p>I work on several Symfony bundles hosted on GitHub and tested automatically with Travis CI.</p>

<p>The longest part of the tests is the installation of the requirements by Composer.</p>

<p>I <a href="https://github.com/alexislefebvre/AsyncTweetsBundle/blob/7c01bd293fe00aa001c9ce1c3cccd64e81a14db7/.travis.yml" rel="nofollow">configured Travis CI</a> to install packages with <code>composer update --prefer-dist</code> and cache the <code>$HOME/.composer/cache</code> directory. Tests took a total time of <a href="https://travis-ci.org/alexislefebvre/AsyncTweetsBundle/builds/102834777" rel="nofollow">18 minutes</a>, thanks to caching:</p>

<blockquote>
  <p>Installing doctrine/lexer (v1.0.1)</p>
  
  <p>Loading from cache</p>
</blockquote>

<p>But a week ago I saw a message from Composer:</p>

<blockquote>
  <p>Installing doctrine/lexer (v1.0.1)</p>
  
  <p>Downloading: Connecting...    Failed to download doctrine/lexer from dist: Could not authenticate against github.com</p>
</blockquote>

<p>I <a href="https://github.com/alexislefebvre/AsyncTweetsBundle/blob/5daffa9ecf70fe74bba93d11263521ca098a73c2/.travis.yml" rel="nofollow">changed the configuration</a> to <code>composer update --prefer-source</code> because of this. This seems to be a common practice across Symfony bundles. The tests suite took <a href="https://travis-ci.org/alexislefebvre/AsyncTweetsBundle/builds/105789907" rel="nofollow">28 minutes</a>.</p>

<p>I know that I can register GitHub keys in Travis CI in order to avoid the API limit while using the Composer <code>--prefer-dist</code> option.</p>

<p>Are they some other ways to cache the dependencies? E.g by cloning the dependencies repositories in a cache?</p>