@@ -19,62 +19,60 @@ Use cache for dependencies, like packages you download from the internet.
...
@@ -19,62 +19,60 @@ Use cache for dependencies, like packages you download from the internet.
Cache is stored where GitLab Runner is installed and uploaded to S3 if
Cache is stored where GitLab Runner is installed and uploaded to S3 if
[distributed cache is enabled](https://docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching).
[distributed cache is enabled](https://docs.gitlab.com/runner/configuration/autoscale.html#distributed-runners-caching).
- You can define it per job by using the `cache:` keyword. Otherwise it is disabled.
- You can define it per job so that:
- Subsequent pipelines can use it.
- Subsequent jobs in the same pipeline can use it, if the dependencies are identical.
- You cannot share it between projects.
Use artifacts to pass intermediate build results between stages.
Use artifacts to pass intermediate build results between stages.
Artifacts are generated by a job, stored in GitLab, and can be downloaded.
Artifacts are generated by a job, stored in GitLab, and can be downloaded.
- You can define artifacts per job. Subsequent jobs in later stages of the same
Both artifacts and caches define their paths relative to the project directory, and
pipeline can use them.
can't link to files outside it.
- You can't use the artifacts in a different pipeline.
### Cache
- Define cache per job by using the `cache:` keyword. Otherwise it is disabled.
- Subsequent pipelines can use the cache.
- Subsequent jobs in the same pipeline can use the cache, if the dependencies are identical.
- Different projects cannot share the cache.
### Artifacts
- Define artifacts per job.
- Subsequent jobs in later stages of the same pipeline can use artifacts.
- Different projects cannot share artifacts.
Artifacts expire after 30 days unless you define an [expiration time](../yaml/README.md#artifactsexpire_in).
Artifacts expire after 30 days unless you define an [expiration time](../yaml/README.md#artifactsexpire_in).
Use [dependencies](../yaml/README.md#dependencies) to control which jobs fetch the artifacts.
Use [dependencies](../yaml/README.md#dependencies) to control which jobs fetch the artifacts.
Both artifacts and caches define their paths relative to the project directory, and
can't link to files outside it.
## Good caching practices
## Good caching practices
To ensure maximum availability of the cache, when you declare `cache` in your jobs,
To ensure maximum availability of the cache, do one or more of the following:
use one or more of the following:
-[Tag your runners](../runners/configure_runners.md#use-tags-to-limit-the-number-of-jobs-using-the-runner) and use the tag on jobs
-[Tag your runners](../runners/configure_runners.md#use-tags-to-limit-the-number-of-jobs-using-the-runner) and use the tag on jobs
that share their cache.
that share the cache.
-[Use runners that are only available to a particular project](../runners/runners_scope.md#prevent-a-specific-runner-from-being-enabled-for-other-projects).
-[Use runners that are only available to a particular project](../runners/runners_scope.md#prevent-a-specific-runner-from-being-enabled-for-other-projects).
-[Use a `key`](../yaml/README.md#cachekey) that fits your workflow (for example,
-[Use a `key`](../yaml/README.md#cachekey) that fits your workflow. For example,
different caches on each branch). For that, you can take advantage of the
you can configure a different cache for each branch.