How to enable / setup Dependency Caches for apt-get on BitBucket Pipelines : <p>I am using the following code in my <code>bitbucket-pipelines.yml</code> files to remotely deply code to a staging server.</p>

<pre><code>image: php:7.1.1

pipelines:
  default:
    - step:
        script:
          # install ssh
          - apt-get update &amp;&amp; apt-get install -y openssh-client
          # get the latest code
          - ssh user@domain.com -F ~/.ssh/config "cd /path/to/code &amp;&amp; git pull"
          # update composer
          - ssh user@domain.com -F ~/.ssh/config "cd /path/to/code &amp;&amp; composer update --no-scripts"
          # optimise files
          - ssh user@domain.com -F ~/.ssh/config "cd /path/to/code &amp;&amp; php artisan optimize"
</code></pre>

<p>This all works, except that each time the pipeline is run, the ssh client is downloaded and installed everything (adding ~30 seconds to the build time). Is there way I can cache this step?</p>

<p>And how can I go about caching the <code>apt-get</code> step?</p>

<p>For example, would something like this work (or what changes are needed to make the following work):</p>

<pre><code>pipelines:
  default:
    - step:
        caches:
          - aptget
        script:
          - apt-get update &amp;&amp; apt-get install -y openssh-client

definitions:
  caches:
    aptget: which ssh
</code></pre>
